[OT] Perl woes

Andy Armstrong andy at hexten.net
Wed Jan 28 12:08:35 GMT 2009


On 28 Jan 2009, at 10:56, Jonathan Kimmitt wrote:
> 	It would be a trivial matter to return an error or warning if ==
> is used for items which aren't numbers

Not at compile time - it's not generally knowable. At run time you / 
do/ get a warning:

perl -w -le 'print q(a)==q(b)'
Argument "b" isn't numeric in numeric eq (==) at -e line 1.
Argument "a" isn't numeric in numeric eq (==) at -e line 1.
1

(Assuming you use warnings - which I assume you are if you're  
interested in, er, warnings)

You can get even more information about the warning using splain:

perl -w -le 'print q(a)==q(b)' 2>&1 | splain
Argument "b" isn't numeric in numeric eq (==) at -e line 1 (#1)
     (W numeric) The indicated string was fed as an argument to an  
operator
     that expected a numeric value instead.  If you're fortunate the  
message
     will identify which operator was so unfortunate.

Argument "a" isn't numeric in numeric eq (==) at -e line 1 (#1)
1

> 	And this is in a language which is praised for its powerful
> string handling !


Yes.

-- 
Andy Armstrong, Hexten





More information about the london.pm mailing list