Hello citi2015,
I meant Perl’s design decision to remove the aliasing when @_ is assigned-to within a subroutine.
You can, of course, do the swap by explicitly accessing the subroutine arguments as individual elements of @_:
sub swap { my $temp = $_[0]; $_[0] = $_[1]; $_[1] = $temp; }
— but note the necessity of “remembering” the initial value of $_[0] by storing it in a temporary variable. And I think that answers my question: if the aliasing were not removed, @_ = reverse @_ would produce wrong results, because some elements would be changed (assigned-to) before they were assigned-from.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: Accessing Arguments inside Subroutines via @_
by Athanasius
in thread Accessing Arguments inside Subroutines via @_
by citi2015
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |