Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Your call to
ChangeArray6(@A); Passes the elements of @A into the subroutines @_. Your implementation of "sub ChangeArray6" updates the contents of @_ which were previously aliased to the contents of @A. Note: Only the contents of @_ were changed. The contents of @A were not. Here are two alternative ways to update the contents of @A:
In the sample above, the change made to @_ is RETURNED, then ASSIGNED to @a, changing @a.
In the second piece of code, we pass a REFERENCE to @a. The subroutine assigns new content to the thing(array ref-de-referenced) that it's first parameter referenced (@a). See 'perldoc perlref'. Python is a racist language what with it's dependence on white space! In reply to Re: Changing an array from a sub
by NetWallah
|
|