[ABE.pm] arg isn't numeric?
Phil R Lawrence
phil at five-lawrences.com
Wed Feb 11 15:14:02 CST 2004
Ricardo SIGNES wrote:
> * Phil Lawrence <prlawrence at lehigh.edu> [2004-02-11T11:30:36]
>>use Date::Calc qw( :all );
>
> This is just a bit of evangelism, but: Do look at using DateTime...
> http://datetime.perl.org/
You know, I missed the DateTime talk at YPAC last year, and just never
looked into it. Will do!
>>my $begin = shift();
>>my $end = shift();
>>my $per = shift();
>
>
> Providing defaults would be nice:
> my $begin = shift || do { print "using default begin"; "2003-01-01" };
>
> You could do some nice validation here, too.
> $begin = '2003-01-01' unless $begin =~ /^\d{4}-\d{2}-\d{2}$/;
>
> There's probably a Regex::Common for iso dates.
And, validation would have immediately caught my mistake for me! It's
tricky to balance quicky code writing for tests with the danger of
overengineering and time wasting.
>>print "begin: ", $begin, "\n";
>>print "end: ", $end, "\n";
>>print "per: ", $per, "\n";
>>print "delta: ", $delta, "\n";
>>print "intrvl: ", $intrvl, "\n";
>
>
> Prime candidate for a here-doc.
Hadn't thought of that. Quite right. Reminds me of my favorite
personal idiom, for specifying SQL statements in perl:
my $sth = $dbh->prepare(<<'');
SELECT foo
,bar
FROM baz
$sth->execute(...);
Looks nice with the blank line after the SQL!
Phil
More information about the ABE-pm
mailing list