Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How come @_ gets changed here?

by tobyink (Abbot)
on Jun 10, 2017 at 10:36 UTC ( #1192470=note: print w/replies, xml ) Need Help??


in reply to How come @_ gets changed here?

No, @_ is an alias to the sub's arguments. That's how things like chomp work:

sub my_chomp { $_[0] =~ s/\r?\n\z//sm; } my $var = "foo\n"; my_chomp $var; print "[[$foo]]\n";

perlsub says:

The array @_ is a local array, but its elements are aliases for the actual scalar parameters.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1192470]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-07-16 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (330 votes). Check out past polls.

    Notices?