@
ErrorsCollection

@

Synthesised documentation from language/variables

From language/variables

See Original text in context

Similar to the $ variable, there is also a Positional anonymous state variable @.

sub foo($x{
    say (@).push($x);
}
 
foo($_for ^3;
 
# OUTPUT: «[0] 
#          [0 1] 
#          [0 1 2]␤»

The @ here is parenthesized in order to disambiguate the expression from a class member variable named @.push. Indexed access doesn't require this disambiguation but you will need to copy the value in order to do anything useful with it.

sub foo($x{
    my $v = @;
    $v[$x= $x;
    say $v;
}
 
foo($_for ^3;
 
# OUTPUT: «[0] 
#          [0 1] 
#          [0 1 2]␤»

As with $, each mention of @ in a scope introduces a new anonymous array.