in reply to Re^2: array element return syntax
in thread array element return syntax

-w will help you understand what's going on.

$ perl -we "print (localtime(time))[2]" print (...) interpreted as function at -e line 1. syntax error at -e line 1, near ")[" Execution of -e aborted due to compilation errors.

use diagnostics is even better.

$ perl -Mdiagnostics -we "print (localtime(time))[2]" print (...) interpreted as function at -e line 1 (#1) (W syntax) You've run afoul of the rule that says that any list op +erator followed by parentheses turns into a function, with all the list operators arguments found inside the parentheses. See perlop/Terms and List Operators (Leftward).

So stop the parentheses looking like a function.

$ perl -e "print +(localtime(time))[2]" 16
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg