Re: lc() with undefined arg
- From: "Tassilo v. Parseval" <tassilo.von.parseval@xxxxxxxxxxxxxx>
- Date: Fri, 12 Aug 2005 07:52:13 +0200
Also sprach Stephen Hildrey:
> Len@xxxxxxxxxxxx wrote:
>> Is it documented that lc() doesn't mind an undefined argument ?
>
> I can't see it documented, but it is a common idiom when using CGI.pm to
> use:
>
> my $foo = lc(param('foo'));
>
> for exactly the purpose you describe - supressing the undef warnings.
>
> I am not a Perl internals hacker, but at a guess (and I am probably
> wrong) this source looks relevant:
>
> if (!len) {
> SvUTF8_off(TARG); /* decontaminate */
> sv_setpvn(TARG, "", 0);
> SETs(TARG);
> }
>
> (perl 5.8.6 - pp.c lines 3587 - 3591)
It's not really surprising that this behaviour is implemented somewhere
in the source. However, the code you quote is common in string handling
routines that usually upgrade undef to the empty string. The actual
check for emitting the warning normally happens before. But not in the
case of (uc|lc)(_first)? and possibly others for no apparent reason.
I'm inclined to say this is a bug unless someone is able to explain the
reasoning behind that behaviour.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
.
- Follow-Ups:
- Re: lc() with undefined arg
- From: ced@xxxxxxxxxxxxxxxxxxxxx
- Re: lc() with undefined arg
- References:
- lc() with undefined arg
- From: Len
- Re: lc() with undefined arg
- From: Stephen Hildrey
- lc() with undefined arg
- Prev by Date: Re: Noob wants Q&D pointer, regexp replacement.
- Next by Date: Re: sort
- Previous by thread: Re: lc() with undefined arg
- Next by thread: Re: lc() with undefined arg
- Index(es):