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

Re: need regular expression

by davido (Cardinal)
on Nov 02, 2005 at 08:46 UTC ( #504867=note: print w/replies, xml ) Need Help??


in reply to need regular expression

The following will work correctly if the year is specified as 0, 1, 11, 111, or even 1111 (ones representing any digit):

use strict; use warnings; my( @dates ) = ( '4-10-31', '14-11-31' ); foreach my $date ( @dates ) { my $string = $date; $string =~ s/^(\d+)/ my $year=2000; substr($year,4-length($1),length($1))=$1; $year/e; print $string, "\n"; }

You can even override '2000' as being the base year by including the entire four-digit year, as in "1987-10-31".


Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2019-11-12 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (64 votes). Check out past polls.

    Notices?