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
Clinton A. Pierce
September 26, 2000 21:01
Re: [ID 20000926.002] substr with undef values is not consistant
Message ID:
Ronald J Kimball wrote:
> C<undef + 4>, C<"hi!" . undef>, and C< undef << 2 > could all result in
> undef, and that would be a reasonable implementation, but it's not how Perl
> works.

That's not what I'm arguing here.  I'm not arguing that substr(undef, 0)
should return undef necessarily.  I'm arguing that substr(undef, 1)
should return whatever substr(undef, 0).  I don't CARE which.  undef or
"", take your pick, but don't flip-flop based on positional logic. 
Seeing substr behave this way gives me the creepy feeling that I'm
looking at C code which reads:

        char s[]="Hello, world";
        printf("%s", &s[1]);   /* See! It's still there! */

That's my position, and I'm sticking to it.  At least until I've had a
good night's sleep and still think that substr beyond-the-end-of-undef
should behave that way.

How do I measure undef?  Let me count the ways.
I measure thee to the depth and breadth and height
My undef can reach, when feeling out of sight
For the ends of NULL and empty arrays.

    Clinton A. Pierce              Teach Yourself Perl in 24 Hours!         for details see
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About