|There's more than one way to do things|
local vs myby rzward (Monk)
|on Sep 02, 2002 at 14:27 UTC||Need Help??|
rzward has asked for the
wisdom of the Perl Monks concerning the following question:
I have a script that makes heavy use of 'local' rather than 'my'. This is because the script was originally written in 1996 and supporting Perl 4 was important. I have updated and enhanced the script quite a bit and have up to now decided to not use 'my' because I didn't see a real need.
I would now like to use 'use strict' but 'use strict' doesn't regard 'local' as a way of defining a variable, so I get many "... requires explicit package name at..." messages.
I remember reading somewhere that 'local' works whereas 'my' doesn't when dealing with file handles... Am I remembering incorrectly? I can't find this.
I am now considering changing all occurrences of 'local' in the script to 'my' but am worried that this will break the code. Are there places where I can read about the differences between 'my' and 'local'?
Thanks in advance.