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

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

Thread Previous | Thread Next
From:
Chas. Owens
Date:
July 28, 2010 01:49
Subject:
Re: [perl #76756] PATCH: srand returns the seed
Message ID:
AANLkTikzZJU_EP-p-RYOYUVahu4S94sUwHwfu4VNH9NT@mail.gmail.com
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:

print chr ord scalar qw eof write and
print qq pop xor print chr ord qq and
quotemeta xor lc print chr ord scalar
qw seek fork x keys and print chr ord
reverse q each y binmode xor uc print
chr ord q defined and int srand print
chr ord reverse q kill hex print link
and print chr oct ord sqrt oct uc ord
scalar qw pack dump xor print chr ord
reverse q do rand xor print chr ord q
read qr xor print chr int ord reverse
qw fileno s printf and print chr sqrt
ord reverse q each chomp pack binmode

Of course, that is my own fault.  The srand function did not document
what it returns and I blindly trusted that it always returned a true
value.  The fix is pretty simple too:

print chr ord scalar qw eof write and
print qq pop xor print chr ord qq and
quotemeta xor lc print chr ord scalar
qw seek fork x keys and print chr ord
reverse q each y binmode xor uc print
chr ord q defined and int srand print
chr ord reverse q kill hex print link
xor print chr oct ord sqrt oct uc ord
scalar qw pack dump xor print chr ord
reverse q do rand xor print chr ord q
read qr xor print chr int ord reverse
qw fileno s printf and print chr sqrt
ord reverse q each chomp pack binmode

I guess it is time to print up new business cards.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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