Leser: 1
10 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9
use strict, etc. pp. my $max = @PICS; for my $i( 0 .. $max ) { $Pictures .= "PIC:<br><img src=\"$PICS[$i]\" alt=\"$CAPTIONS[$i]\" border=\"0\" class=\"GalleryPic\">CAPTION:<br>$CAPTIONS[$i]"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; my @pics = map { sprintf "%02d.jpg", $_ } 1..6; my @captions = qw( quark mehl tomate schinken kaese ananas ); for my $i ( 0 .. $#pics ) { print <<BILDINFO; PIC:<br> <img src="$pics[$i]" alt="$captions[$i]" border="0" class="gallery_pic" /> CAPTION:<br> $captions[$i] BILDINFO }
1
2
3
4
5
<b>Hans im Glück auf Mallorca</b>
Hier sieht man in beim Bananabootfahren.
<b>Marry Poppins auf der Weihnachtsfete</b>
Sie verteilt Süßigkeiten an die Kinder
1 2 3 4 5
# Variante 1 my ($caption) = split(/^\n*$/,$line); #Variante 2 my ($caption) = split(/\n\n/,$line);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
sub GetGalleryFileAndCaptions { my ($URLpicdir,$PATHpicdir) = @_; return "Error: couldn't build gallery. The following directory does not exist: $PATHpicdir" if not (-d "$PATHpicdir"); my @allfiles = (); my @dirs = (); my @CAPTIONS = (); my @PICS = (); my $PicDisplayReturn = ""; &untaint( \$PATHpicdir ) or return "Could not untaint directory: $PATHpicdir\n"; opendir(DIR, "$PATHpicdir") or return "Could not open: $PATHpicdir"; @allfiles = sort( readdir( DIR ) ); closedir(DIR); for my $file (@allfiles) { if (-d "$PATHpicdir$file") { push @dirs, $file unless (($file eq ".") or ($file eq "..")); } else { my ($extension) = $file =~ /\.([^.]+?)$/; $extension = lc($extension); push @PICS, $file if ($extension eq "jpg"); } } my $CaptionFile = $PATHpicdir."bu.txt"; open DATA, "<$CaptionFile" or return qq|Program Error! Could not open file: $CaptionFile. Debugging information: $!|; chomp (my @LINES = <DATA>); close DATA; for my $line (@LINES) { $line =~ s/\015\012|\012|\015/\n/sg; } for my $line (@LINES) { my ($caption) = split(/^\n*$/,$line); { push(@CAPTIONS,$caption); } } for my $p (0 .. $#PICS) { $PicDisplayReturn .= "PIC:<br><img src=\"$URLpicdir$PICS[$p]\" alt=\"$CAPTIONS[$c]\" border=\"0\" class=\"GalleryPic\"><br>CAPTION:<br>$CAPTIONS[$c]<hr>"; } #$PicDisplayReturn =~ s/\015\012|\012|\015//sg; return $PicDisplayReturn; }
1 2 3 4 5 6 7 8
open my $rfh, '<', $CaptionFile or return "$CaptionFile: open(ro) failed: $!\n"; { # perldoc perlvar local $/ = "\n\n"; @captions = <$rfh>; chomp @captions; } close $rfh or die "$CaptionFile: close(ro) failed: $!\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
sub GetGalleryFileAndCaptions { my ($URLpicdir,$PATHpicdir) = @_; return "Error: couldn't build gallery. The following directory does not exist: $PATHpicdir" if not (-d "$PATHpicdir"); my @allfiles = (); my @dirs = (); my @CAPTIONS = (); my @PICS = (); my $PicDisplayReturn = ""; opendir(DIR, "$PATHpicdir") or return "Could not open: $PATHpicdir"; @allfiles = sort( readdir( DIR ) ); closedir(DIR); for my $file (@allfiles) { if (-d "$PATHpicdir$file") { push @dirs, $file unless (($file eq ".") or ($file eq "..")); } else { my ($extension) = $file =~ /\.([^.]+?)$/; $extension = lc($extension); push @PICS, $file if ($extension eq "jpg"); } } my $CaptionFile = $PATHpicdir."bu.txt"; #open DATA, "<$CaptionFile" or return qq|Program Error! Could not open file: $CaptionFile. Debugging information: $!|; #chomp (my @LINES = <DATA>); #close DATA; open my $rfh, '<', $CaptionFile or return qq|Program Error! Could not open file: $CaptionFile. Debugging information: $!|; { # perldoc perlvar local $/ = ""; @CAPTIONS = <$rfh>; chomp @CAPTIONS; } close $rfh or return qq|Program Error! Could not close file: $CaptionFile. Debugging information: $!|; # for my $line (@LINES) # { # $line =~ s/\015\012|\012|\015/\n/sg; # } # for my $line (@LINES) # { # my ($caption) = split(/\n\n/,$line); # { # push(@CAPTIONS,$caption); # } # } for my $p (0 .. $#PICS) { $PicDisplayReturn .= "PIC:<br><img src=\"$URLpicdir$PICS[$p]\" alt=\"$CAPTIONS[$c]\" border=\"0\" class=\"GalleryPic\"><br>CAPTION:<br>$CAPTIONS[$c]<hr>"; } #$PicDisplayReturn =~ s/\015\012|\012|\015//sg; return $PicDisplayReturn; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
sub GetGalleryFileAndCaptions { my ($URLpicdir,$PATHpicdir) = @_; return "Error: couldn't build gallery. The following directory does not exist: $PATHpicdir" if not (-d "$PATHpicdir"); my @allfiles = (); my @dirs = (); my @CAPTIONS = (); my @PICS = (); my $PicDisplayReturn = ""; opendir(DIR, "$PATHpicdir") or return "Could not open: $PATHpicdir"; @allfiles = sort( readdir( DIR ) ); closedir(DIR); for my $file (@allfiles) { if (-d "$PATHpicdir$file") { push @dirs, $file unless (($file eq ".") or ($file eq "..")); } else { my ($extension) = $file =~ /\.([^.]+?)$/; $extension = lc($extension); push @PICS, $file if ($extension eq "jpg"); } } my $CaptionFile = $PATHpicdir."bu.txt"; open my $rfh, '<', $CaptionFile or return qq|Program Error! Could not open file: $CaptionFile. Debugging information: $!|; { # perldoc perlvar # $INPUT_RECORD_SEPARATOR local $/ = "\r\n\r\n"; @CAPTIONS = <$rfh>; chomp @CAPTIONS; } close $rfh or return qq|Program Error! Could not close file: $CaptionFile. Debugging information: $!|; for my $i (0 .. $#PICS) { $PicDisplayReturn .= "<img src=\"$URLpicdir$PICS[$i]\" alt=\"$CAPTIONS[$i]\" border=\"0\" class=\"GalleryPic\"><br>$CAPTIONS[$i]<br><br>"; } $PicDisplayReturn =~ s/\015\012|\012|\015//sg; return $PicDisplayReturn; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
sub GetGalleryFileAndCaptions { #.... #open DATA, "<$CaptionFile" or return qq|Program Error! Could not open file: $CaptionFile. Debugging information: $!|; #chomp (my @LINES = <DATA>); #close DATA; ################################################################ # Den ganzen Datensatz auf einmal einlesen my $data=''; open my $rfh, '<', $CaptionFile or return qq|Program Error! Could not open file: $CaptionFile. Debugging information: $!|; { # perldoc perlvar local $/ = undef; $data = <$rfh>; } close $rfh or return qq|Program Error! Could not close file: $CaptionFile. Debugging information: $!|; # Das "\r" entfernen $data=~tr/\x0D//d; # Daten splitten my @CAPTIONS=split(/\x0A\x0A/,$data); ################################################################ for my $p (0 .. $#PICS) { $PicDisplayReturn .= "PIC:<br><img src=\"$URLpicdir$PICS[$p]\" alt=\"$CAPTIONS[$c]\" border=\"0\" class=\"GalleryPic\"><br>CAPTION:<br>$CAPTIONS[$c]<hr>"; } #$PicDisplayReturn =~ s/\015\012|\012|\015//sg; return $PicDisplayReturn; }
10 Einträge, 1 Seite |