Quicksilver has asked for the wisdom of the Perl Monks concerning the following question:
As this pattern may or may not exist in the line, I just wanted to effect a light swap using a hash rather than trying to call Date::parse since there is no standard pattern.sub num_month { my $date = shift; my %months = (JAN => '01', FEB => '02', MAR => '03', APR => '04', MAY=> '05', JUN => '06', JUL => '07', AUG => '08', SEP => '09', OCT => '10', NOV => '11', DEC => '12'); my @tokens = split (" ", $date); my $date; foreach my $num (@tokens) { my $strBegin = substr($num, 0, 3); my $date =~ s/$strBegin/$months{uc $strBegin}/; } return $date; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A quick date swap from a string
by toolic (Bishop) on Jul 08, 2009 at 20:44 UTC | |
|
Re: A quick date swap from a string
by zwon (Abbot) on Jul 08, 2009 at 20:46 UTC | |
|
Re: A quick date swap from a string
by jrsimmon (Hermit) on Jul 08, 2009 at 21:05 UTC | |
|
Re: A quick date swap from a string
by Marshall (Canon) on Jul 09, 2009 at 05:03 UTC | |
|
Re: A quick date swap from a string
by mattford63 (Sexton) on Jul 08, 2009 at 22:01 UTC | |
by shawnhcorey (Friar) on Jul 09, 2009 at 04:14 UTC | |
|
Re: A quick date swap from a string
by ashish.kvarma (Monk) on Jul 09, 2009 at 09:00 UTC | |
|
Re: A quick date swap from a string
by poolpi (Hermit) on Jul 09, 2009 at 08:15 UTC | |
|
Re: A quick date swap from a string
by ggoebel (Sexton) on Jul 10, 2009 at 18:21 UTC |