Re: Switching with case in perl ?
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Sun, 9 Sep 2007 05:14:47 +0100
Quoth "Petr Vileta" <stoupa@xxxxxxxxxxxxx>:
lerameur wrote:
for my $minute (0..59) {
my $logtime = strftime("%y%m%d%H%M", 0, $minute, $hours, $day, $month
-1, $year + 100), "\n"; #line 20
print $logtime,"\n";
}
error: Useless use of constant in void context at line 20.
Not an error: a warning. The distinction is important.
Maybe you have format or parameters in reverse order :-)
You can write this
my $logtime = strftime("%y%m%d%H%M\n", $year + 100, $month -1, $day, $hours,
$minute);
I think you're confusing strftime with sprintf. The former does not
expect its parameters in the order they are used, it expects a whole
broken-out 'struct tm' (second, minute, hour, day, month, year in that
order). See perldoc POSIX.
my $logtime = strftime("%y%m%d%H%M", $year + 100, $month -1, $day, $hours,
$minute) . "\n";
# use dot for concate instead comma operator
The comma operator never concatenates... the mystery is why the OP
thought it did :).
Ben
.
- Follow-Ups:
- Re: Switching with case in perl ?
- From: Petr Vileta
- Re: Switching with case in perl ?
- References:
- Switching with case in perl ?
- From: lerameur
- Re: Switching with case in perl ?
- From: Joe Smith
- Re: Switching with case in perl ?
- From: lerameur
- Re: Switching with case in perl ?
- From: Petr Vileta
- Switching with case in perl ?
- Prev by Date: A flexible multi-level UL/LI constructor
- Next by Date: FAQ 2.15 Where can I buy a commercial version of perl?
- Previous by thread: Re: Switching with case in perl ?
- Next by thread: Re: Switching with case in perl ?
- Index(es):
Relevant Pages
|