|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re^2: style guidanceby 7stud (Deacon) |
| on Nov 09, 2009 at 00:02 UTC ( [id://805824]=note: print w/replies, xml ) | Need Help?? |
|
Thanks for the guidance. I'm trying to digest it all. Don't assign to a global variable without localising it. You just clobbered your parent's data. I guess you mean like this:
By the way, I'm calling all user defined functions using the syntax &func() because the llama 5th ed. merely says that the & prevents name clashes with perl functions, therefore beginners should use the & until they become familiar with the names of perl functions. However, from the comments I gather there is more to it than that. I don't understand what local() does differently than my(). I read the docs, and I don't understand the difference.
or even safer:
sub do_stuff1 {
${ local *_ } = shift;
chomp;
say;
}
The latter handles the case where $_ is tied or otherwise magical.
What does that * notation do, and could you give some more details why that is safer than local $_? Maybe an example? Thanks.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||