On Wed, 2005-03-16 at 03:18, Rod Adams wrote:
> I just posted a fresh copy of S29 to:
> 
>  http://www.rodadams.net/Perl/S29.pod
>  http://www.rodadams.net/Perl/S29.html

>From there:

        =head2 Obsolete

        =item chop

Chop removes the last character from a string. Is that no longer useful,
or has chomp simply replaced its most common usage?

        chomp($x)

vs

        substr($x,-1) = '';

Hrm... well, I guess it's not SO bad....

        =item dbmopen, dbmclose

YAY! ;)

        =item dump
        
        With Parrot?

Yes, but it won't be the same, and it should probably come from a
module. I'm sure that's going to be required by several folks from
several different areas (e.g. for checkpointing and all of the uses that
come from that like process migration). It will also be 99% Parrot's
job.

        =item srand
        
        C<rand(:seed($x))>

Ah, no. C<rand(:seed($x))> will invoke rand, will it not? That's not
what srand does. srand puts you in a known state, and leaves you there.
Without srand, even if you're using the same PRNG, you can't plug in
someone else's seed, and then call the function that will use it, unless
you can rewind/unshift the PRNG.

That said, I'd very much like Perl 6 to provide (either through Parrot
or on its own) a default strong, non-blocking random number generator
out of the box (though ALSO a rand that's just a PRNG which does not
exhaust the system's entropy pool). It's very frustrating to not have a
reliable way to get at least passable random numbers. The way I do this
in Perl 5:

        BEGIN{
                eval "use Math::TrulyRandom";
                if ($@) {
                        foreach my $file (qw(/dev/urandom /dev/random)) {
                                if (-r $file) {
                                        no strict;
                                        *truly_random_value = sub {
                                                use bytes;
                                                local *F;
                                                open F, "<$file" or die "$file: 
$!";
                                                my $b;
                                                sysread(F,$b,4)==4 or die 
"$file: $!";
                                                close F;
                                                return unpack("I",$b);
                                        };
                                        last;
                                }
                        }
                        if (!defined \&truly_random_value) {
                                die "No Math::TrulyRandom and no 
/dev/(u)random\n$@";
                        }
                }
        }

I'd like to stop doing that ;-)

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to