chrisvmarle
06-29-2004, 12:33 PM
I have a piece of code to create html-files of pictures in a dir. I would like to create a link to the next picture on each page.
The problem is, I don't know how to get the name of the next picture in @list.
Here's a piece of my code:
# code removed here
print "open dir $dir\n";
opendir(DIR, "$dir");
print "reading dir\n";
my @list = sort(grep(/.jpg$/i, readdir(DIR)));
closedir(DIR);
# code removed here
foreach my $item (@list)
{
(my $basename, my $extension) = split(/\./, $item);
# lots of code removed here
$nextlink = ""; # I need the value of the next $item here
print "creating html file\n";
open(FILE,">$dir/$basename.html") || die("Couldn't create new html file ($dir$
print FILE qq~<html><head><title>$basename</title></head>
<body>
<center>
<img src="$fulls/$item" width="$newfw" height="$newfh" border="0"><br>
$prevlink$toplink$nextlink
</center>
</body></html>~;
close(FILE);
$prevlink = qq~<a href="$basename.html">prev</a> ~;
}
Any suggestions how to fill $nextlink with the right link?
Thanks in advance
The problem is, I don't know how to get the name of the next picture in @list.
Here's a piece of my code:
# code removed here
print "open dir $dir\n";
opendir(DIR, "$dir");
print "reading dir\n";
my @list = sort(grep(/.jpg$/i, readdir(DIR)));
closedir(DIR);
# code removed here
foreach my $item (@list)
{
(my $basename, my $extension) = split(/\./, $item);
# lots of code removed here
$nextlink = ""; # I need the value of the next $item here
print "creating html file\n";
open(FILE,">$dir/$basename.html") || die("Couldn't create new html file ($dir$
print FILE qq~<html><head><title>$basename</title></head>
<body>
<center>
<img src="$fulls/$item" width="$newfw" height="$newfh" border="0"><br>
$prevlink$toplink$nextlink
</center>
</body></html>~;
close(FILE);
$prevlink = qq~<a href="$basename.html">prev</a> ~;
}
Any suggestions how to fill $nextlink with the right link?
Thanks in advance