Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Use a date module :)

by mugwumpjism (Hermit)
on Jun 23, 2005 at 00:36 UTC ( [id://469253]=note: print w/replies, xml ) Need Help??


in reply to splitting a string into arbitrary lengths

If you're splitting a date into its components, why not use a Date module?

use Time::Piece; my $time = Time::Piece->strptime("20050622", "%Y%m%d"); my ($tyear, $tmon, $tday) = ($time->year, $time->mon, $time->mday)

Ok, it's not quite as small as a straight regex match, but quite often when you are playing with dates manually like this, it pays to use a module like Time::Piece, DateTime or even Date::Manip. The advantages now don't seem worth it - but as you start to work with dates more, you'll appreciate having objects for them so you can do calculations on them without missing things.

$h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found