in reply to Array iteration: foreach works, for doesn't
sub parse_datetime($) { $_ =~ /(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/; return($1, $2, $3, $4, $5); }
You're not using the argument you pass to parse_datetime, but $_, which is a global variable.
Try
instead.sub parse_datetime($) { my $s = shift; $s =~ /(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/; return($1, $2, $3, $4, $5); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array iteration: foreach works, for doesn't
by Dźwiedziu (Initiate) on Nov 23, 2009 at 13:43 UTC |