in reply to Strange construct

It's (part) of a list slice. List slices are documented in perldata.

[ Of the three existing posts, neither of those facts were mentioned!?! ]

A list slice has the following form:

( EXPR )[ EXPR ]

Of the scalars returned by the left EXPR, the slice returns those identified by the indexes returned by the right EXPR.

( 'foo', 'bar', 'baz' )[ 0, 2, 4 ] # 'foo', 'baz', undef

The scalars are returned in the order identified by the indexes. Negative indexes index from the end like with arrays. (-1 = last, -2 = second last, etc)

Replies are listed 'Best First'.
Re^2: Strange construct
by dlal66 (Acolyte) on Sep 07, 2011 at 21:14 UTC
    Thank you to all who replied. I am always surprised to see the various syntaxes/constructs in perl that are not used regularly or even mentioned in books...