[ABE.pm] Re: making things more perlish

Faber Fedor faber at linuxnj.com
Sat Jan 8 07:08:07 PST 2005


On 08/01/05 01:30 -0500, Jim Eshleman wrote:
> Long ago I decided to use Date::Calc for these kinds of things, 

Now he tells me!

> is how I would do it.  I know it doesn't really answer your question but 
> thought it may be of some use...

It raises some usage Q, such as...

> #!/usr/bin/perl -w
> 
> use Date::Calc qw(:all);

Why include the 'qw(:all)'?


> sub ldopm {
> 
>     # Get the last day of the previous month
> 
>     my $ymdstr = shift;

You're doing a shift cuz you only have one argument?

>     my @ymd;
> 
>     if ($ymdstr) {
>         @ymd = $ymdstr =~ /(\d\d\d\d)(\d\d)(\d\d)/;

See!  More Perl-ish! That's what I'm talking about!

>         check_date(@ymd) or die "ldopm: invalid date '$ymdstr'\n";

check_date() is a function I write?

>     } else {
>         @ymd = Today();
>     }
> 
>     return sprintf "%04d%02d%02d", Add_Delta_Days(@ymd, -$ymd[2]);

I'll look into this Add_Delta_Days thing. As RJBS pointed out, DateTime
is a bit unwiedly.


-- 
 
Regards,
 
Faber                     

Linux New Jersey: Open Source Solutions for New Jersey
http://www.linuxnj.com





More information about the ABE-pm mailing list