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
piledriver.

--keith

--
kkeller-usenet@xxxxxxxxxxxxxxxxxxxxxxxxxx
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

.



Relevant Pages

  • Re: [RegEx] Optional parameter
    ... >> on every script since the -W flag was added. ... I know at least two cases where perl prints nonsense ... RW> warnings and use of 'no warning' is thus entirely legitimate: ...
    (comp.lang.perl.misc)
  • Re: Zonealrm: Need to identify the source of outgoing request
    ... Rod Engelsman wrote: ... out by warnings about svchost.exe, smss.exe, etc. (all legitimate ... windows networking components) accessing the Net. ...
    (comp.security.firewalls)
  • Re: buildworld is broken ?
    ... S> head, amd64 Revision: 245588 ... cc1: warnings being treated as ... [head tinderbox] failure on ia64/ia64 ...
    (freebsd-current)
  • Drive Cleaner
    ... Is Drive Cleaner a legitimate application? ... "blue" site I was suddenly swamped with legitimate looking warnings that I ... should immediately use "drivecleaner" to clean my machine - so many warnings ...
    (microsoft.public.access.security)
  • Re: [RegEx] Optional parameter
    ... All "uninitialized" means in this context is that no value has actually ... legitimate for hash keys to have a corresponding value of undef. ... that it enables warnings unconditionally despite their ...
    (comp.lang.perl.misc)