So, if you want modifiable scalar parameters, you can change them inside a sub by using $_[0], $_[1] etc. as lvalues without resorting to references. Interesting.
Also, I am reminded of how $_ gets bound to successive members of an array:
Is the same true if you use an intermediate variable - does it get aliased, or merely assigned? Apologies: I don't have access to a machine running Perl at the momentforeach (@foo) { $_++; # Add 1 to each member of @foo }
Also I'm wondering about the future of all this. What of behaviour in Perl 6? Coming back to the first scenario, I hear that Perl 6 will be getting some Ruby features. Does this include passing parameters by name and hence Jensen's device?foreach my $bar (@foo) { $bar++; }
--rW
Note: magicality - this might be a new term I am coining. Magicality bears as much relation to magic as sexuality does to sex.
In reply to Thoughts on the magicality of @_ and $_ by rinceWind
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |