CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...: Re: [sangiro] Perl code (SSI) to detect day and time: Edit Log



yapp
User

Feb 23, 2002, 2:27 AM


Views: 5466
Re: [sangiro] Perl code (SSI) to detect day and time


In Reply To
What would the code look like if I wanted to display "true" between between 9pm on Wednesday and 6am on Thursday


Give it a try:
I guess this should work.

[perl]
use strict; # allways use this, get used to it!
use constant WEDNESDAY => 3;
use constant THURSDAY => 4;

# or gmtime() for GMT time
my(undef,undef,$hour,undef,undef,undef,$wday) = localtime();

if((WEDNESDAY <= $wday && $hour <= 9) && ($wday <= THURSDAY && $hour <= 18)) {
print "This is between wed 6:00 and thu 18:00\n";
}
else {
print "Definitely not!\n";
}
[/perl]

btw, "use constant X => 1" is just a cool way of saying "sub X(){1}", which results in a in-lined subroutine.

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool

(This post was edited by yapp on Feb 23, 2002, 2:29 AM)


Edit Log:
Post edited by yapp (User) on Feb 23, 2002, 2:28 AM
Post edited by yapp (User) on Feb 23, 2002, 2:28 AM
Post edited by yapp (User) on Feb 23, 2002, 2:29 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives