Thread Zwei Arrays "synchron" ausgeben (9 answers)
Opened by cbxk1xg at 2008-11-23 15:18

cbxk1xg
 2008-11-23 17:09
#116553 #116553
User since
2003-10-20
496 Artikel
BenutzerIn
[default_avatar]
So, ich hab's! Danke Linuxer!

Der Code, nicht schön aber selten:
Code (perl): (dl )
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;
}

View full thread Zwei Arrays "synchron" ausgeben