http://qs321.pair.com?node_id=193108


in reply to scrambling keys of a hash (was: Fellow monks;)

What exactly do you mean by ``scrambling'': randomizing it, or encrypting it so nobody can pear into its contents?

In the first case you probably want to have a look at Data::Random, which you can use like this snippet:

#!/usr/bin/perl -w use strict; use Data::Random qw(:all); use Data::Dumper; my @keys = qw(aap noot mies bert ernie klaas tentamen college); print "Before:\n" . Dumper( @keys ) . "\n"; my @random_set = rand_set( set => \@keys, size => $#keys + 1 ); print "After:\n" . Dumper( @random_set ) . "\n";

For encryption you can use various ways Crypt::Des for example.

Good Luck!

Changed the name of refered module to the correct one & added size operand to `rand_set' to get complete input set back (in random order)

-- JaWi

"A chicken is an egg's way of producing more eggs."

Replies are listed 'Best First'.
Re: Re: Fellow monks;
by Sihal (Pilgrim) on Aug 27, 2002 at 10:37 UTC
    Wow! I didn't know about this module Data::Rand. That's exactly what I needed, thanx.