Hi haukex
thank you for your comments. I'm not fully convinced yet, though.
When you localize a glob, you're localizing every variable with that name - scalars, arrays, hashes, etc.Sure. But I can keep a reference to those if needed. Or I can choose a different name for the file handle.
local's effects have dynamic scope, so they effect everything called in that scope, including code that might not be yours. You might step on someone else's globals, or they might step on yours. The major issue is that this is action at a distance: things may break in remote pieces of code, and it may be incredibly hard to connect the problem to the cause. This will not happen with lexicals.As shown in my example, the usage in another package does no harm.
Bareword filehandles also clash with package names (see also).Is this an issue occuring in real life? Probably I do not understand this in all detail yet.
Still using barewords :-)
Greetings,
-jo
In reply to Re^2: lexical vs. local file handles
by jo37
in thread lexical vs. local file handles
by jo37
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |