Prev: FAQ 6.12 Can I use Perl regular expressions to match balanced text?
Next: FAQ 7.9 How do I create a module?
From: sreservoir on 18 Jan 2010 22:18 On 1/18/2010 9:58 PM, Ben Morrow wrote: > > Quoth sreservoir<sreservoir(a)gmail.com>: >> On 1/18/2010 9:40 PM, sreservoir wrote: >>> On 1/18/2010 9:05 PM, Ben Morrow wrote: >>>> >>>> No. False in perl is canonically a dualvar that is the empty string in >>>> string context and 0 in numeric context (so there are no warnings on >>>> numeric conversion, unlike a plain ""). >>>> >>>> ~% perl -E'say defined !1' >>>> 1 >>>> ~% perl -wE'say 0 + !1' >>>> 0 >>>> ~% perl -wE'say "[", ("" . !1), "]"' >>>> [] >>>> ~% perl -wE'say 0 + ""' >>>> Argument "" isn't numeric in addition (+) at -e line 1. >>>> 0 >>>> ~% >>>> >>>> True is canonically the string "1". >>> >>> ~% perl -wle'print !1' >>> Use of uninitialized value in print at -e line 1. >>> >>> ~% >>> >>> I suspect this is a historical thing that I never remembered. >> >> a newer perl returns the same results as your perl. > > Which version of perl was your original test? I get !1 defined for all > versions>5.6.0 (the oldest perl I have lying around). whatever version it is that ships with fedora core 1. I never did get that one to connect to the internet. probably perl 5.6.0 or a 5.004. yes, I probably should update it. sue me -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe"
From: sreservoir on 18 Jan 2010 22:21 On 1/18/2010 10:06 PM, Ben Morrow wrote: > > Quoth sreservoir<sreservoir(a)gmail.com>: >> On 1/18/2010 9:28 PM, J�rgen Exner wrote: >>> sreservoir<sreservoir(a)gmail.com> wrote: >>>> because 0 is, traditionally, not true, even in perl where false is >>>> canonically undef. >>> >>> That is not correct. While the boolean values of undef is indeed false, >>> this is by no means canonical. There are several other scalar values, >>> the numerical 0 just being one of them. Please see 'perldoc perldata' >>> for details. >> >> huh. historically, the comparisons returned undef for false. well, I >> guess you learn something new every day. > > I don't know what you mean by 'historically'. sv_no (the canonical false > value) has been as I describe since 5.000; 4.036 had str_no, which > appears to be simply the empty string (I guess Perl 4 didn't have > numeric conversion warnings?). I am now slightly confused, too. Must have been confused and/or sleep- deprived when I thought that. Though I'm not sure how !1 managed to emit the warning then. -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe"
From: Tad McClellan on 18 Jan 2010 22:45 sreservoir <sreservoir(a)gmail.com> wrote: > the problem with this group is .... This group has no problems. You must have us confused with some other group. -- Tad McClellan email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
From: sreservoir on 18 Jan 2010 23:03 On 1/18/2010 10:45 PM, Tad McClellan wrote: > sreservoir<sreservoir(a)gmail.com> wrote: > >> the problem with this group is > ... > > > This group has no problems. > > You must have us confused with some other group. > No, just confusing it with some other definition of problem. -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe"
From: Uri Guttman on 19 Jan 2010 00:22
>>>>> "BM" == Ben Morrow <ben(a)morrow.me.uk> writes: BM> Quoth "Uri Guttman" <uri(a)StemSystems.com>: >> >>>>> "BM" == Ben Morrow <ben(a)morrow.me.uk> writes: >> BM> Quoth sreservoir <sreservoir(a)gmail.com>: >> >> >> >> because 0 is, traditionally, not true, even in perl where false is >> >> canonically undef. >> BM> No. False in perl is canonically a dualvar that is the empty string in BM> string context and 0 in numeric context (so there are no warnings on BM> numeric conversion, unlike a plain ""). >> >> i know that but the OP's issue was not knowing that 0 was false or not >> getting that if checked for false and not defined. BM> I know you know that, which is why I wasn't saying it to you. I was BM> saying it to sreservoir, who apparently didn't. then you should have replied to his post and not mine. :) uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- |