|Problems? Is your data what you think it is?|
Whether to use local()by jerrygarciuh (Curate)
|on Mar 15, 2002 at 18:28 UTC||Need Help??|
jerrygarciuh has asked for the
wisdom of the Perl Monks concerning the following question:
While this is not an OO question, it was prompted by theDamian's OO Perl (which I got for my b-day (not bidet). OO Perl Ch1 talks about Objects sharing attributes and methods they need and not those they don't. I have also seen objections here at PM that a var declared with my at the top level of a script is a pseudo-global and therefore bad form.
My question is whether you should be concerned with scope if $new_mail needs to be shared between sub update_mail_list and sub read_mail_list etc. Do you take care to use local to control scope? Or do you simply declare my $new_mail at the topmost level so the whole script has access? The latter is so easy, why would you go to the trouble of using local if you aren't trying to keep some private value of $new_mail somewhere?I hope my question is clear.
It's not my tree.