in reply to Global, Local, what the..?
I don't think I understand the previous answers.
To me, the crux is that when you pass scalars to a subroutine, @_ actually contains aliases to the scalars themselves so that modifying $_[0] directly actually modifies the caller's scalar. Similarly, modifying $_ in a map, for, or foreach actually modifies the elements of the list that you are looping over.
So $_ is an alias for $_[0] which is an alias for the caller's $value and $value gets modified in-place and the return value doesn't matter because you call the function in a void context and the return value is thrown away.
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid - subroutine return example w/map)
by Ovid (Cardinal) on Dec 15, 2000 at 03:26 UTC | |
by tye (Sage) on Dec 15, 2000 at 03:34 UTC |