K Pfeiffer wrote:
> 
> This lost me for a moment. I figured it out by trying...
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> # test "get uc month from localtime"
> 
> my $month = qw(JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV
> DEC)[(localtime)[4]];
> 
> print localtime,"\n";
> my $x = localtime[4]; print "$x\n";
> print "$month\n";
> 
> With this result:
> 325927910202990
> Mon Apr 15 08:17:32 1974
> OCT
> 
> I then made this change (added parens):
> my $x = (localtime)[4]; print $x,"\n";
> 
> which yields "9" as expected. (Your way might be better if I later want to
> change "OCT" to "October" or "10th month" etc.?)
> 
> So what did "localtime[4]" (without parens) do?

my $x = localtime[4];

Is the same as:

my $x = localtime;

Which assigns the scalar value of localtime to $x.  The [4] part is
ignored.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to