
Kenosis
User
Mar 22, 2013, 10:42 PM
Post #3 of 6
(138 views)
|
|
Re: [dprogrammer] if then else with Date help needed
[In reply to]
|
Can't Post
|
|
To get the day of the month, you can use the following: localtime(time) returns a list, detailed here. The third item of the list is the day. Using Perl's ternary operator, consider the following:
#!/usr/bin/env perl use strict; use warnings; my $con = ( localtime(time) )[3] == 1 ? 'D:\\MyFiles\con_1.conf' : 'D:\\MyFiles\con_2.conf'; print $con; Output: However, it will return: when it's the first day of the month, i.e., when:
( localtime(time) )[3] == 1 is true. Hope this helps!
(This post was edited by Kenosis on Mar 23, 2013, 9:05 AM)
|