in reply to passing an array without a name to pop()
The syntax for pop is
which meanspop ARRAY pop
pop @NAME pop @BLOCK pop EXPR->@* pop
The block and the expression are expected to evaluate to a reference to an array. [ ... ] creates an array and a reference to it, and evaluates to a reference. This means you can use:
pop @{ [ 2, 4, 6 ] }
or
pop [ 2, 4, 6 ]->@*
Note that EXPR->@* requires Perl 5.24+. It's also available in Perl 5.20+ by adding both use feature qw( postderef ); and no warnings qw( experimental::postderef );, or by adding use experimental qw( postderef );.
|
|---|