in reply to printing element of anonymous array

This is because Perl sees something else, it associates the parentheses with print():

print(gmtime(time)) [6];

This makes no sense to Perl.

To fix this, you need one more set of parentheses:

print( (gmtime(time))[6] );

Replies are listed 'Best First'.
Re^2: printing element of anonymous array
by perltux (Monk) on Mar 03, 2018 at 15:39 UTC
    Many thanks for the quick explanation and solution!