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";
|
|---|