[LA.pm] Spam:***, Re: little help??

Peter Benjamin pete at peterbenjamin.com
Thu Sep 29 10:56:42 PDT 2005


At 08:00 PM 9/28/2005, Mike Dillon wrote:
>> my $hour = (split, localtime)[2];

I've read a lot of code that uses perl shortcuts.
It's obtuse.  Not a new argument regarding perl.

For a programmer new to perl, though, I feel spelling
out the full import of the functionality of the line
can often lead to faster code re-use.  For example:

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

is a copy and paste from Perl/html/lib/Pod/perlfunc.html#item_localtime
and I just use it, over and over, rather than try to recall what
subscript is the hour.

When more than just the hour is needed, I know exactly what variables to use.

Yes, do read shortcut code, and understand that shortcut is there
and how the shortcut works for it's scope and context, as that
can lead to very advance use of perl, and in one line do something
that would otherwise take 10 lines.  But when first starting to use
perl... I advise to learn the easy way, where the perl Help copy
and paste method is quite clear, and debugging is non-existent,
resulting in faster time to working code, and moving on to the
next perl project.




More information about the Losangeles-pm mailing list