Re: [RegEx] Optional parameter
- From: Keith Keller <kkeller-usenet@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 9 Jun 2011 15:03:12 -0700
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
.
- Follow-Ups:
- Re: [RegEx] Optional parameter
- From: Peter J. Holzer
- Re: [RegEx] Optional parameter
- From: Rainer Weikusat
- Re: [RegEx] Optional parameter
- References:
- [RegEx] Optional parameter
- From: Scottie
- Re: [RegEx] Optional parameter
- From: Rainer Weikusat
- Re: [RegEx] Optional parameter
- From: Wolf Behrenhoff
- Re: [RegEx] Optional parameter
- From: Alan Curry
- Re: [RegEx] Optional parameter
- From: Rainer Weikusat
- [RegEx] Optional parameter
- Prev by Date: Re: [RegEx] Optional parameter
- Next by Date: Re: [RegEx] Optional parameter
- Previous by thread: Re: [RegEx] Optional parameter
- Next by thread: Re: [RegEx] Optional parameter
- Index(es):
Relevant Pages
|