P is for Practical | |
PerlMonks |
Re^3: Accessing Arguments inside Subroutines via @_by Athanasius (Archbishop) |
on Mar 20, 2015 at 07:54 UTC ( [id://1120702]=note: print w/replies, xml ) | Need Help?? |
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 @_:
— 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,
In Section
Seekers of Perl Wisdom
|
|