develooper Front page | perl.perl5.porters | Postings from August 2012

Re: fixing smartmatch just hard enough (and when, too)

Thread Previous | Thread Next
From:
demerphq
Date:
August 20, 2012 10:24
Subject:
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
CANgJU+XVH1TDXi5LF_TNJ62z0_nC9m+SJ2_oFU1EOi0t6D0RKg@mail.gmail.com
On 20 August 2012 14:44, Johan Vromans <jvromans@squirrel.nl> wrote:
> Damian Conway <damian@conway.org> writes:
>
>> A simple failure-case I have already mentioned privately to Rick is this:
>>
>>    while (readline) {
>>         when (undef)    { say 'done'; last;  }
>>         when (0)        { say 'must be +ve'; }
>>         when (any 1..9) { say 'digit';       }
>>         default         { die 'horribly';    }
>>     }
>>
>> ...which dies horribly even when a single digit is correctly typed in.
>
> I assume this is because of the trailing newline?
> If so, I think it should die. "1" is not equal to "1\n" even though atoi
> fans will claim so.

But perl considers "1" numerically equvalent to "1\n", and as far as I
can tell without warning either:

$ perl -wle'print 1 if "1" == "1\n"'
1

and actually, the only thing I find weird here is that it *doesn't* warn.

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About