...
/Implicit Ideas: The Default Array Variables
Implicit Ideas: The Default Array Variables
Learn about the default array variables in Perl.
We'll cover the following...
We'll cover the following...
Function arguments array: @_
Perl provides two implicit array variables. Perl passes arguments to functions in an array named @_. Array operations inside functions use this array by default. These two snippets of code are equivalent:
sub foo {my $arg = shift;...}
Just as $_ corresponds to the pronoun “it,” @_ corresponds to the pronouns “they” and “them.” Unlike $_, each function has a separate copy of @_. The built-ins shift and pop operate on @_, if provided no explicit operands.