[Bioperl-l] Grrrr. Another subtle overloading bug ...

Ewan Birney birney@ebi.ac.uk
Mon, 7 Jan 2002 10:18:11 +0000 (GMT)


On Sun, 6 Jan 2002, Aaron J Mackey wrote:

> 
> On Sun, 6 Jan 2002, Ewan Birney wrote:
> 
> >   if( $@ ) triggers the "stringify" method, which gives back a nice piece
> > of text and then gets evaluated as a number (I think...), which goes to 0
> > which evaluates as .... FALSE.
> 
> Since when would any non-empty/non - "0 but true"/non-numeric string
> not be true in a boolean context?  Here's the cases I can see where a
> string would return false:

This is definitely what happens!

  if( $@ =~ /EX/ )  # returns true
  if( $@ ) # returns false


I don't understand it fully either, but that is definitely what is
happening...


> 
> $@ eq "0";
> $@ eq ""
> !defined($@) ; # already said that's not the case
> 
> The only way you'd get what you describe is in constructs like:
> 
> if ( $@ != 0 ) { # force numeric context on $@
> 
> -Aaron
> 
> 

-----------------------------------------------------------------
Ewan Birney. Mobile: +44 (0)7970 151230, Work: +44 1223 494420
<birney@ebi.ac.uk>. 
-----------------------------------------------------------------