Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
# sub to print date sub get_date { my $text = shift or die "No date object passed through"; 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 $dttime = $text =~ m/((?<=_).*)/; $dttime = $1; my $month = $dttime =~ s/(\w{3}).*/$months{uc $1}/; $month = $1; my $year = $dttime =~ m/(\d{4})/; $year = $2; $dttime = $month . "-" . $year; return $dttime; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to convert date from a line of text
by grep (Monsignor) on Jul 07, 2009 at 21:10 UTC | |
|
Re: Trying to convert date from a line of text
by moritz (Cardinal) on Jul 07, 2009 at 20:58 UTC |