in reply to Whether to use local()
Personally, i wouldn't. But the caveat depends on what kind of program you are writing.
When i write utility scripts, avoiding global variables is usually a waste of typing to me - i use them. Keep in mind that i do have a CS degree and my professors would never allow us to use globals ever anywhere! I appreciated that, but now that i understand the rules, i can break them. >:)
Let's say that i am writing a larger program. Then i would strongly consider OO. OO is good for eliminating globals, because you instead have accessor methods (considering, of course, that it is good OO).
Finally, local vs. my - in my limited experience with local, i only use it to erase Perl's built-in variables, like $/ for slurp mode (thanks again tye!):
All of my variables are declared with my. To be honest, i am still missing the picture of when you need our.my $slurp = do {local $/; <FH>};
Hope this helps :)
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Whether to use local()
by tachyon (Chancellor) on Mar 15, 2002 at 19:25 UTC | |
by jeffa (Bishop) on Mar 15, 2002 at 23:11 UTC |