Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Generating a format template for a date

by Hue-Bond (Priest)
on Oct 13, 2006 at 17:17 UTC ( [id://578179]=note: print w/replies, xml ) Need Help??


in reply to Re: Generating a format template for a date
in thread Generating a format template for a date

My solution goes along the same lines, more or less:

my %dateformat = ( '99(.)99(.)99' => '"DD${1}MM${2}RR"', '99(.)99(.)9999' => '"DD${1}MM${2}YYYY"', '9999(.)99(.)99' => '"YYYY${1}MM${2}DD"', ); DATE: while (<DATA>) { ## updated: it was 'foreach' chomp; foreach my $k (keys %dateformat) { next unless /^$k$/; my $trans = $_; $trans =~ s/^$k$/$dateformat{$k}/ee; print "translated <$_> to <$trans>\n"; next DATE; } warn "$_ unmatched\n"; } __DATA__ 99/99/9999 99/99/99 99-99-9999 9999999 9999@99#99

--
David Serrano

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-25 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found