The snippet of code I included in my post was an attempt to come up
with a process that would initialize these fields if they were not
aleady defined. That's why I used the unless defined clause.
By using 'my' you just created this local variable, therefore by
definition this variable will be undefined. Therefore your check for
defined() is meaningless, even if the right-hand side were referencing
the new local variable (it is not!).
Introduce variables when you need them and where you need them. Unless
there are exceptional circumstances you should know the real desired
initial value at that time and there should be no need to initialize
them to some dummy value.
My understanding of this function was that it was the perl equivalent
of the php isset function. However, even when I remove the unless
portion of the statements I still receive the same use of
uninitialized variable blah blah.
I don't believe you.
A
my $ln = '';
compiles and runs perfectly fine, even with strict and warnings enabled.
All I'm trying to do is understand how I can satisfy the syntax so the
programs resume working. They were in production.
Maybe you should think about semantic first. Do you now what "my" does?
If you don't then adding random statements into your code is not likely
to fix anything.
So please keep up the comments as I and I'm sure others find them
informative. And if you understand my issue more clearly perhaps more
suggestions will follow.
Honestly I don't. If you want to refactor your code to take advantage of
new Perl features, then that's great.
But new versions of Perl are usually quite backward compatible.
Therefore usually there is little need to change anything to make older
programs run with newer versions. Yes, that is a generalization and
there are counter-examples, but "my" isn't one of them.
Or to put it in different words: if you want to change your code from
global variables to local variables then IMNSHO this is a great idea.
But it has nothing to do with switching to a newer version of Perl.
jue