kwn has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; my %hash = ( one => 'd$\vic', two => 'd$\daqq', three => 'c$\lol', four => 'd$\bom', five => 'd$\eef', six => 'd$\ff\logs' ); my %hoa = ( "array a" => [ "dd1", "dd2", "dd3", "dd4" ], "array b" => [ "gg1", "gg2", "gg3", "gg4" ], "array c" => [ "cc1", "cc2", "cc3", "cc4" ] ); my $input = <STDIN>; chomp $input; if ((exists $hash{$input})) { foreach my $group(keys %hoa) { foreach (@{$hoa{$group}}) { if ($input = $_) { print "$input found in $group\n"; } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: specific array in hash of arrays
by ikegami (Patriarch) on Oct 09, 2008 at 09:07 UTC | |
|
Re: specific array in hash of arrays
by kwn (Novice) on Oct 09, 2008 at 10:25 UTC | |
by ikegami (Patriarch) on Oct 09, 2008 at 10:55 UTC | |
by gone2015 (Deacon) on Oct 09, 2008 at 13:54 UTC | |
by ikegami (Patriarch) on Oct 09, 2008 at 14:11 UTC | |
by gone2015 (Deacon) on Oct 09, 2008 at 15:01 UTC | |
| |
by kwn (Novice) on Oct 09, 2008 at 11:23 UTC | |
by moritz (Cardinal) on Oct 09, 2008 at 10:35 UTC | |
by kwn (Novice) on Oct 09, 2008 at 11:18 UTC | |
by moritz (Cardinal) on Oct 09, 2008 at 11:27 UTC | |
|
Re: specific array in hash of arrays
by kwn (Novice) on Oct 09, 2008 at 17:08 UTC |