lc() with undefined arg
- From: Len@xxxxxxxxxxxx
- Date: 11 Aug 2005 00:01:11 -0700
I expected this to give a warning for "uninitialized value" :
perl -w -e 'my $abc; print "\L$abc";'
But it doesn't!
Why is this different from:
perl -w -e 'my $abc; print "$abc";'
which DOES give the expected warning ?
Is it documented that lc() doesn't mind an undefined argument ?
Or is something else going on?
I'm interested in this because the following would be kind of neat
if I could trust that it would work cleanly into the future,
even if Flag was missing from the hash:
if ("\L$hash->{'Flag'}" eq 'yes') {...}
If I don't understand why it works, I'll continue to use the rather
messier:
if (lc ($hash->{'Flag'} || '') eq 'yes') {...}
(BTW, about omitting the quotes, as in $hash->{Flag} :
is this considered sound practice, or is it just lazy ?)
Cheers,
-Len
.
- Follow-Ups:
- Re: lc() with undefined arg
- From: Stephen Hildrey
- Re: lc() with undefined arg
- From: Paul Lalli
- Re: lc() with undefined arg
- Prev by Date: Re: FAQ .
- Next by Date: FAQ 3.3 Is there a Perl shell?
- Previous by thread: FAQ .
- Next by thread: Re: lc() with undefined arg
- Index(es):
Relevant Pages
|
|