RSS Forums RSS
Please support our Perl advertiser: Programming Forums
Views: 1431 | Replies: 2 | Thread Tools  Display Modes
Reply
Join Date: Jan 2006
Posts: 28
Reputation: Syakoban is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Syakoban Syakoban is offline Offline
Light Poster

Help Perl script modification needed...

  #1  
Jul 25th, 2007
Hi,

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!



  1. #!/usr/bin/perl
  2. use CGI::Carp qw/fatalsToBrowser/;
  3.  
  4. use strict;
  5. use warnings;
  6.  
  7. # path to folder where images are
  8. # assumes an image named open.gif and closed.gif
  9. my $path = '/home/fireplug/public_html/images/';
  10.  
  11. # time in military format 0-23
  12. # first number is opening time
  13. # second number is closing time
  14. # 24-24 indicates always closed
  15. # server is central standard time so time is adjusted minus 1 hour
  16. my %schedule = (
  17. Sun => [9,11],
  18. Mon => [10,11],
  19. Tue => [10,11],
  20. Wed => [10,11],
  21. Thu => [10,11],
  22. Fri => [10,11],
  23. Sat => [24,24]
  24. );
  25.  
  26. # default value
  27. my $image = 'closed.gif';
  28.  
  29. # get the day and hour
  30. my ($day, $hour) = (split(/ /,scalar localtime))[0,3];
  31. $hour = (split(/:/,$hour))[0];
  32.  
  33. # check the day and hour
  34. if ($schedule{$day}[0] <= $hour && $schedule{$day}[1] > $hour) {
  35. $image = 'open.gif';
  36. }
  37.  
  38. #print appropriate MIME type header
  39. print "Content-type: image/gif\n\n";
  40.  
  41. open(FH,"$path$image") or die "$!";
  42. binmode(FH);
  43. print while (<FH>);
  44. close(FH);
  45. exit;
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 685
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 43
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Perl script modification needed...

  #2  
Jul 26th, 2007
I knew I should have copyrighted that script.
Reply With Quote  
Join Date: Mar 2006
Posts: 685
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 43
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Perl script modification needed...

  #3  
Jul 26th, 2007
see other forum where you have this question posted.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:44 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC