1,105,384 Community Members

Weekdays and Weekend days in perl

Member Avatar
realoneomer
Light Poster
32 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi Perl Masters,

I have a requirements where i need to execute the particular part of code in weekdays (from Moday to Friday & Saturday) and some part on (Sunday)but i don't know that how to check the current day in perl. Like if current day is in between monday to saturday than run weekdays part and if current day is sunday then run other part.

Could you please help me out that how i can extract current day information using perl code..?

Thanks in advance

Member Avatar
erezschatz
Newbie Poster
17 posts since Jan 2011
Reputation Points: 14 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
1
 

use localtime:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

...

$wday is the day of the week, with 0 indicating Sunday and 3 indicating Wednesday.

So basically you need

(localtime(time))[6]
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article