{ # the values of the following hash are subs defined elsewhere my %dispatch = ( dev_random => \&_dev_random, dev_urandom => \&_dev_urandom, random_org => \&_random_org, hotbits => \&_hotbits, ); sub _seed { my $none = $_[ 0 ] eq 'none'; my @methods = @_ if not $none; @seed = (); my $magic_num = magic_num(); while ( @methods ) { my $method = shift @methods; my $need = $magic_num - @seed; if ( @methods && looks_like_number( $methods[0] ) ) { my $n = shift @methods; $need = $n if $n < $need; } unless ( defined $dispatch{ $method } ) { push @errors, "Unsupported seeding method: $method"; next; } push @seed, $dispatch{ $method }->( $need ); last if @seed >= $magic_num; } push @errors, 'Full seed not acquired from sources: ' . @seed if @seed < $magic_num and not $none; push @seed, time, $$; $#seed = $magic_num - 1 if @seed > $magic_num; # Seed the PRNG seed( @seed ); } }