Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: Optimizing the bejeezus out of a sub

by IlyaM (Parson)
on Jun 24, 2003 at 08:55 UTC ( #268427=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Optimizing the bejeezus out of a sub
in thread Optimizing the bejeezus out of a sub

foreach my $section ( @_ ) { ... } doesn't copy value from @_ to $section. In the loop the variable $section is merely an alias to a currently selected element in @_ array. You can even modify @_ array by assigning a new value to $section. Example:

# adds 1 to all elements of array foreach my $elem (@arr) { $elem ++; }

--
Ilya Martynov, ilya@iponweb.net
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://268427]
help
Chatterbox?
shmem puts down the Canon garments and dresses as Chancellor
[vrk]: Congratulations. You should have Cookies
[shmem]: thanks vrk - but I'll rather have a plate of "silly con charme"
Lady_Aleena is trying to explain perl regexen to people right now and explaining how variables expand in regexen.
[Lady_Aleena]: The people I'm talking with think /$var/ looks weird with some saying it shouldn't work.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-04-28 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (520 votes). Check out past polls.