develooper Front page | perl.perl5.porters | Postings from September 2000

Re: [ID 20000926.002] substr with undef values is not consistant

Thread Previous | Thread Next
From:
Rick Delaney
Date:
September 26, 2000 19:01
Subject:
Re: [ID 20000926.002] substr with undef values is not consistant
Message ID:
39D1564B.451F2731@home.com

"Clinton A. Pierce" wrote:
> 
>         no warnings qw(uninitialized);
> 
>         if (defined substr(undef, 0)) {
>                 print "At 0, defined!\n";
>            } else {
>                 print "At 0, not defined!\n";
>         }
> 
>         if (defined substr(undef, 1)) {
>                 print "At 1, defined!\n";
>            } else {
>                 print "At 1, not defined!\n";
>         }
> 
> Results in:
> 
>         At 0, defined!
>         At 1, not defined!

This is exactly what you get for substr("", 0) and substr("", 1), which
makes sense since that's what the "Use of uninitialized value" warning
that you've turned off is telling you.  You also get the same for
substr("x",1) and substr("x",2) so this seems like a logical
progression.

But a question remains.  Why is

    no warnings qw(uninitialized);

suppressing the warning,

    substr outside of string

?

-- 
Rick Delaney
rick.delaney@home.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About