On Thu, 2002-02-21 at 19:49, Larry Wall wrote:
> David M. Lloyd writes:
> : On Thu, 21 Feb 2002, Sam Vilain wrote:
> : 
> : > I can't count the number of times I've had to do something like:
> : >
> : >   if (defined $foo and $foo ne "bar") { }
> : >
> : > to avoid my program writing garbage to STDERR.
> : 
> : Of course you will now be able to say:
> : 
> : if ($foo // "" ne "bar") { }
> : 
> : Right?
> 
> Not quite.  You'd have to say:
> 
>     if ($foo // "") ne "bar" { }
> 
> That's presuming we leave // with the same precedence as ||.


Of course, that's not the same as the original, it just avoids the
warning.

It seems that that may have been the intent, but I'm not sure....
Certainly this change would modify the behavior.

I agree that there should be a simple way to say "I don't want to be
told about undefined values", but I don't know what sorts of cans of
worms that opens. Something like a property might be better:

    my $foo is undefined;
    if ($foo ne "bar") { .... }

Such a declaration seems safer than a global, "don't warn me about it"
directive.


Reply via email to