Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Convert date into day and month

by fishmonger (Hermit)
on Nov 01, 2013 at 13:40 UTC ( #1060762=note: print w/ replies, xml ) Need Help??


in reply to Convert date into day and month

You could use a hash that maps the month name to a number and then use a regex to change the date string.

Example:
#!/usr/bin/perl use strict; use warnings; my %mon2num = ( Sept => 9, Oct => 10, Nov => 11, # etc ); while (<DATA>) { chomp; my ($date, $file_name) = split(/,/); $date =~ s/(\S+)\s(\S+)\s(\S+)/$2 $mon2num{$1} $3/; print "$date\n"; } __DATA__ Oct 31 08:30,file1 Nov 25 17:30,file2 Sept 09 12:00,file3

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060762]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2016-06-25 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (323 votes). Check out past polls.