[OT] Perl woes

Jonathan Stowe jns at integration-house.com
Wed Jan 28 12:29:28 GMT 2009


2009/1/28 Jonathan McKeown <jonathan+londonpm at hst.org.za>:
> On Wednesday 28 January 2009 14:01:22 Paul Makepeace wrote:
>>
>> Interesting that everyone's said to "use warnings" but no-one's
>> questioned what you're saying. Perl appears to me to DTRT:
>>
>> $ perl -le 'print "yes" if "a" == "2"'
>> $ perl -le 'print "yes" if "a" == "a"'
>> yes
>> $ perl -le 'print "yes" if "1" == "1"'
>> yes
>> $ perl -le 'print "yes" if "1" == "0"'
>> $ perl -le 'print "yes" if "1" == 1'
>> yes
>> $
>>
>> Can you give an example where perl is doing something surprising to you?
>
>
> $ perl -le 'print "yes" if "a" == "b"'
> yes
>
> is mildly surprising. Luckily Perl can explain it:
>
> $ perl -wle 'print "yes" if "a" == "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.
> yes

It doesn't adequately explain why they are  equivalent though IMO -
that just indicates that you've probably made a cockup.  If I could be
arsed I'd send a patch to add ' interpreting as 0' to the message :-)

/J\
-- 
http://rabidgravy.com/ - Music
http://gellyfish.co.uk/ - Everything else


More information about the london.pm mailing list