What do square brackets do in Perl?

[] creates an array reference.

[ $scalar, $scalar ] creates an array reference with two items in it.

short($file) calls a subroutine and returns something (probably a scalar or a list of scalars)

-s $file gives you the size of the file (as a scalar).

[short($file), -s $file] gives you an array ref containing the above two things.


It creates a reference to an array with two items, the result of a function call to short($file) and the size of the $file.

Tags:

Literals

Perl