Re: [RegEx] Optional parameter

On 2011-06-09, Rainer Weikusat <rweikusat@xxxxxxxxxxx> wrote:

Out of my head, I know at least two cases where perl prints nonsense
warnings and use of 'no warning' is thus entirely legitimate:

- the already mentioned case of the 'uinitialized variable':
Technically, there is no such thing as an 'unitialized
variable' in Perl (meaning, something whose value is
essentially random, as would be the case in C). All
variables start out with a value of 'undef' and this will be
interpreted as 0 or '' if need be.

All "uninitialized" means in this context is that no value has actually
been assigned by the program. I consider it extremely useful in
situations where, for example, you have a data structure where you
expect values to be assigned but there isn't

foreach my $key (@expectedKeys) {
print $hash->{$key};

If a $hash->{$key} value hasn't been assigned to, I want to know that,
because it's likely a bug.

And, of course, using no warnings 'uninitialized' in areas where you
know that there will be uninitialized variables will suppress the
warning for you. Telling people not to use "use warnings;" because you
don't like the uninitialized warning is like driving a brad with a


(try just my userid to email me)
see X- headers for PGP signature information