develooper Front page | perl.perl5.porters | Postings from July 2010

Re: [perl #76756] PATCH: srand returns the seed

Thread Previous | Thread Next
From:
demerphq
Date:
July 28, 2010 07:34
Subject:
Re: [perl #76756] PATCH: srand returns the seed
Message ID:
AANLkTik=tugH447eU-Z=3+YHSr5BXKrjaYf75XBgR1HD@mail.gmail.com
On 28 July 2010 16:17, Chas. Owens <chas.owens@gmail.com> wrote:
> On Wed, Jul 28, 2010 at 10:07, karl williamson <public@khwilliamson.com> wrote:
>> Nicholas Clark wrote:
>>>
>>> On Wed, Jul 28, 2010 at 04:48:52AM -0400, Chas. Owens wrote:
>>>>
>>>> On Tue, Jul 27, 2010 at 12:23, karl williamson
>>>> <perlbug-followup@perl.org> wrote:
>>>>>
>>>>> # New Ticket Created by  karl williamson
>>>>> # Please include the string:  [perl #76756]
>>>>> # in the subject line of all future correspondence about this issue.
>>>>> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76756 >
>>>>>
>>>>>
>>>>> Attached
>>>>>
>>>> If the seed can every be 0, then this breaks the following very important
>>>> code:
>>>
>>>> I guess it is time to print up new business cards.
>>>
>>> No need:
>>>
>>> commit da1010ecc50c91387eed9bcc349e6960909a3484
>>> Author: Nicholas Clark <nick@ccl4.org>
>>> Date:   Wed Jul 28 11:01:51 2010 +0100
>>>
>>>    Make srand() return "0 but true" for 0, for backwards compatible
>>> behaviour.
>>>
>>>
>>> (which I had suggested as part of the original discussion)
>>>
>>> Nicholas Clark
>>>
>> But you suggested it in such a way that it went right over my head.  I
>> didn't understand what you meant; and thought you were being funny, cause I
>> don't have the background to to get it.  I'll have to examine your changes.
>>
>
> "0 but true", "0e0", "0.0", and a couple other strings are true values
> (because they aren't the string "0"), but don't elicit the 'Argument
> "%s" isn't numeric%s' warning.
>
> perl -wE 'say $_ + 1, $_ ? " true" : " false" for qw/ 0 0.0 0e0 /, "0
> but true", "0 but dkfjnkerfnk"'
>
> 1 false
> 1 true
> 1 true
> 1 true
> Argument "0 but dkfjnkerfnk" isn't numeric in addition (+) at -e line 1.
> 1 true

In particular 0E0 and variants are well known amongst people that use
DBI, as DBI uses it for the "updated 0 rows, but no error occured".

so you see stuff like

my $rows= $dbh->do("update Foo set blah=?",undef,$var)
  or die "Cant update Foo: ",$dbh->errstr();
print "Updated ", 0+$rows, " rows\n";

very regularly...

yves
-- 
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