pglenski has asked for the wisdom of the Perl Monks concerning the following question:
So I decide to create a hash of arrays. The individual elements I can "see" -- for example, $tbl{"key"}[0] is correct. So can't I grep thru this too? See code below.@tmp = grep /${text}/,@array_of_something
perl -de ' foreach $i (map {glob} "COMFILE1.2008*") { open(IN,$i); chomp(@tmp = (<IN>)); $tbl{$i} = [ @tmp ] ; close(IN); } open(IN,"dw_renewals.txt"); while(<IN>) { chomp; foreach $i (sort keys %tbl) { @tmp = [ @tbl{$i} ]; if (grep /$_/, [ @tbl{$i} ] ) { print "$_ in $i $y\n"; } } } '
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: greping thru a hash of arrays
by pc88mxer (Vicar) on May 20, 2008 at 20:58 UTC | |
by pglenski (Beadle) on May 20, 2008 at 21:10 UTC | |
by linuxer (Curate) on May 20, 2008 at 21:15 UTC | |
by pc88mxer (Vicar) on May 20, 2008 at 21:19 UTC | |
|
Re: greping thru a hash of arrays
by johngg (Canon) on May 20, 2008 at 22:16 UTC |