Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: What are multiple $_[0] =~ operations doing?

by cog (Parson)
on Apr 01, 2005 at 09:43 UTC ( #444129=note: print w/replies, xml ) Need Help??


in reply to What are multiple $_[0] =~ operations doing?

some kind of dynamic referencing

Take the following code, for instance:

my @a = (1, 2, 3); add(@a); sub add { for (@_) { $_++; } }

Now try printing @a; it contains (2, 3, 4), because the add() function acted directly upon it's arguments.

Likewise, your statements are changing the first input parameter directly, by performing substitutions upon $_[0], which is the first value of @_.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://444129]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-01-18 01:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?