I
Ian Wilson
Which X and Y in `perldoc -X Y` will explain why we need parentheses
around localtime in
#!/usr/bin/perl
use strict;
use warnings;
my ($d,$m,$y) = (localtime)[3,4,5];
printf (" Today is %02d/%02d/%04d\n", $d, $m+1, $y+1900);
AFAIK Perl uses parentheses for list context and for precedence, I think
they are used here to force a list context?
In the assignment statement, since the LHS is a list, I'd have thought
it would supply a list context to the RHS anyway.
Also, it superficially appears to me that the [3,4,5] ought to be a hint
that the thing to the left ought not to be interpreted in a scalar context.
I've read perldoc -f localtime and perused my blue Camel.
Clearly I'm missing something fundamental :-(
around localtime in
#!/usr/bin/perl
use strict;
use warnings;
my ($d,$m,$y) = (localtime)[3,4,5];
printf (" Today is %02d/%02d/%04d\n", $d, $m+1, $y+1900);
AFAIK Perl uses parentheses for list context and for precedence, I think
they are used here to force a list context?
In the assignment statement, since the LHS is a list, I'd have thought
it would supply a list context to the RHS anyway.
Also, it superficially appears to me that the [3,4,5] ought to be a hint
that the thing to the left ought not to be interpreted in a scalar context.
I've read perldoc -f localtime and perused my blue Camel.
Clearly I'm missing something fundamental :-(