If you take the route of specifying the offset, I would recommend using a constant instead of a magic number. It makes thins a tad easier to read.
use constant DAY_OF_MONTH => 3;
my $day = (localtime)[DAY_OF_MONTH];
print "Day is @{ [ ( localtime )[DAY_OF_MONTH] ] }\n";
While I like the hackishness of the @{[()[]]} approach to forcing interpolation of executing code, I think it's too unweildy--it's hard to type and hard to read. If you really want to go this route, check out Interpolation--an interesting module that started out as a joke.
|