Someone put together a small perl script for me that uses day and time to determine which of two images to display (open.gif or closed.gif). I need to modify the script to also include a hyperlink to open.html or closed.html so that if the open image is displayed it uses the open.html link and the closed to closed.html. The corresponding web page that loads the image is ultra basic, with a link to the .pl script as the image tag.

Can anyone help a real perl novice (me!) with this one?

Thanks guys!

use CGI::Carp qw/fatalsToBrowser/;

use strict;
use warnings;

# path to folder where images are
# assumes an image named open.gif and closed.gif
my $path = '/home/fireplug/public_html/images/';

# time in military format 0-23
# first number is opening time
# second number is closing time
# 24-24 indicates always closed
# server is central standard time so time is adjusted minus 1 hour
my %schedule = (
Sun => [9,11],
Mon => [10,11],
Tue => [10,11],
Wed => [10,11],
Thu => [10,11],
Fri => [10,11],
Sat => [24,24]

# default value
my $image = 'closed.gif';

# get the day and hour
my ($day, $hour) = (split(/ /,scalar localtime))[0,3];
$hour = (split(/:/,$hour))[0];

# check the day and hour
if ($schedule{$day}[0] <= $hour && $schedule{$day}[1] > $hour) {
$image = 'open.gif';

#print appropriate MIME type header
print "Content-type: image/gif\n\n";

open(FH,"$path$image") or die "$!";
print while (<FH>);
9 Years
Discussion Span
Last Post by KevinADC
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.