If you call a sub with a single scalar, it's the same as calling it with a 1-element list. @_ will contain the one scalar, and you can get it with shift. If you want to call a sub with multiple arrays or hashes and not have them flattened, you need to use references, and you probably want to look at something like perlreftut. If you call a sub with a single array and you want to get all the elements out at once, you can use:
ormy @args=@_; # or my %args=@_ if you know it's going to be a hash
the second form there assumes you know how many arguments you're going to get, or don't care if some of them come back undef.my ($arg1, $arg2, $arg3) = @_; # faster than (shift,shift,shift)
In reply to Re^3: Returning and passing data to and from subroutines
by ssandv
in thread Returning and passing data to and from subroutines
by vendion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |