[ABE.pm] Re: making things more perlish
Jim Eshleman
jce0 at Lehigh.EDU
Sat Jan 8 07:49:29 PST 2005
>>use Date::Calc qw(:all);
>
>
> Why include the 'qw(:all)'?
Imports all functions from the module. You could also list just those
you need if you're "tight with a byte".
>>sub ldopm {
>>
>> # Get the last day of the previous month
>>
>> my $ymdstr = shift;
>
>
> You're doing a shift cuz you only have one argument?
Yep.
>> check_date(@ymd) or die "ldopm: invalid date '$ymdstr'\n";
>
>
> check_date() is a function I write?
No, check_date() is provided by Date::Calc.
>> 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.
Date::Calc also has a Days_in_Month function so you could subtract one
from the month using Add_Delta_YMD, then use Days_in_Month. But just
subtracting the day of month from the date, resulting in the date of the
last day of the previous month, seemed easier.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://mail.pm.org/pipermail/abe-pm/attachments/20050108/99faadf6/signature.bin
More information about the ABE-pm
mailing list