On Monday, June 24, 2002, at 05:10 , Will Shiver wrote:

> black robo

plan A:

        my %kombo = (
        blue    => 'box',
        red     => 'robo',
        purple  => 'rain',
        green   => 'box',
        black   => 'robo',
        );

hence one would read with say

        while(<FH>) {
                s/^\s*//;       # strip leading white space
                my ($key, $stuff) = split(' ');
                print "$key $kombo{$key}\n";
        }

plan B:
        my @type_of_Thing = qw/box robo rain/;
        my %kombo_B = (
                blue    => 0,
                red     => 1,
                purple  => 2,
                green   => 0,
                black   => 1,
        );

hence one would read with say

        while(<FH>) {
                s/^\s*//;       # strip leading white space
                my ($key, $stuff) = split(' ');
                print "$key $kombo{$key}\n";
        }
$plan = "C";

@type_of_Thing = qw/box robo rain/;
my %kombo_C = (
        blue    => $type_of_Thing[0],
        red     => $type_of_Thing[1],
        purple  => $type_of_Thing[2],
        green   => $type_of_Thing[0],
        black   => $type_of_Thing[1],
);

hence you would use Plan A's Read....

cf:

http://www.wetware.com/drieux/pbl/perlTrick/hashIndirection.txt

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to