in reply to List vs array printing in perl

If you allow Perl to tell you more by enabling warnings, the following might help you:

> perl -wle 'print (getpwnam(traveler))[2,3];' print (...) interpreted as function at -e line 1. Unquoted string "traveler" may clash with future reserved word at -e l +ine 1. syntax error at -e line 1, near ")[" Execution of -e aborted due to compilation errors.

The print uses your set of parentheses as its function call parameters. Thus, the additional square brackets make no sense to Perl. Add another set of parentheses to tell Perl what you mean:

> perl -e 'print( (getpwnam(traveler))[2,3] );' Unquoted string "traveler" may clash with future reserved word at -e l +ine 1. The getpwnam function is unimplemented at -e line 1.