T
Tuxedo
What is the best/simplest way to create the following clickthrough
procedure?
A perl script (display.pl) has a cgi-parameter that will show an image, by
accessing for example display.pl?img=img_xyz.jpg
use warnings;
use strict;
use CGI qw(param);
my $img = param("img");
print "Content-Type: text/html\n\n";
my @images = ("image_001.jpg",
"image_002.jpg",
"image_xyz.jpg",
"image_zzz.jpg);
# ???
# find the index position of by matching $img string
# to print out $link_before and $link_after below
# ???
print "<a href=display.pl$link_before>";
print "<img src=$img>";
print "<a href=display.pl$link_after>";
------------------
The image names are kept in an array but not necessary in a numerical order
name form.
How can the corresponding index number of the matching $img cgi-string be
found and extracted in order to print out the link to the next
($link_after) and previous image ($link_before) items found in the array?
Of course, this would only be functional as long as each array item has a
unique name, which they would have.
The html output when accessing display.pl?img=img_xyz.jpg could be:
<a href=display.pl?img=image_002.jpg>previous</a>
<img src=image_xyz.jpg>
<a href=display.pl?img=image_zzz.jpg>next</a>
But while displaying either the first or last image, the link value could
simply loop to the end or the start of the array.
Alternatively, the opening and closing <a..></a> could be omitted when the
position is either at the beginning or the end of the array. So for
example, if accessing display.pl?img=image_zzz.jpg, the output can then be:
<a href=display.pl?img=image_xyz.jpg>previous</a>
<img src=image_zzz.jpg>
next
Any ideas how to best do the above would be appreciated.
Many thanks!
Tuxedo
procedure?
A perl script (display.pl) has a cgi-parameter that will show an image, by
accessing for example display.pl?img=img_xyz.jpg
use warnings;
use strict;
use CGI qw(param);
my $img = param("img");
print "Content-Type: text/html\n\n";
my @images = ("image_001.jpg",
"image_002.jpg",
"image_xyz.jpg",
"image_zzz.jpg);
# ???
# find the index position of by matching $img string
# to print out $link_before and $link_after below
# ???
print "<a href=display.pl$link_before>";
print "<img src=$img>";
print "<a href=display.pl$link_after>";
------------------
The image names are kept in an array but not necessary in a numerical order
name form.
How can the corresponding index number of the matching $img cgi-string be
found and extracted in order to print out the link to the next
($link_after) and previous image ($link_before) items found in the array?
Of course, this would only be functional as long as each array item has a
unique name, which they would have.
The html output when accessing display.pl?img=img_xyz.jpg could be:
<a href=display.pl?img=image_002.jpg>previous</a>
<img src=image_xyz.jpg>
<a href=display.pl?img=image_zzz.jpg>next</a>
But while displaying either the first or last image, the link value could
simply loop to the end or the start of the array.
Alternatively, the opening and closing <a..></a> could be omitted when the
position is either at the beginning or the end of the array. So for
example, if accessing display.pl?img=image_zzz.jpg, the output can then be:
<a href=display.pl?img=image_xyz.jpg>previous</a>
<img src=image_zzz.jpg>
next
Any ideas how to best do the above would be appreciated.
Many thanks!
Tuxedo