in reply to Re^2: Printing hash key shows obscure values - can this be trimmed/removed?
in thread Printing hash key shows obscure values - can this be trimmed/removed?

egrep has a -v flag...

Replies are listed 'Best First'.
Re^4: Printing hash key shows obscure values - can this be trimmed/removed?
by yasmarina (Initiate) on Apr 28, 2015 at 14:15 UTC
    Am looking to read into 2 tab-delimited files. Build a key and compare values. Those differences are output. I'd like to know an easier way to print the entire record of the differences as opposed to using UNIX grep via the key.

      Still not sure what you are looking for...

      use strict; use warnings; my %hBase = ( 'a;a' => 1, 'b;b' => 2, 'c;c' => 3 ); my %hPost = ( 'a;a' => 1, 'b;b' => 3, 'd;d' => 4 ); my %allKeys = map {$_=>1} keys %hBase, keys %hPost; for my $key (keys %allKeys) { if( exists $hBase{$key} and exists $hPost{$key} ) { if( $hBase{$key} eq $hPost{$key} ) { print "$key in both hashes with same value $hBase{$key}\n"; } else { print "$key in both hashes with different values $hBase{$key} != + $hPost{$key}\n"; } } else { print "$key in %hBase with value $hBase{$key}\n" if exists $hBase{ +$key}; print "$key in %hPost with value $hPost{$key}\n" if exists $hPost{ +$key}; } }