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

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.
  • Comment on Re^4: Printing hash key shows obscure values - can this be trimmed/removed?

Replies are listed 'Best First'.
Re^5: Printing hash key shows obscure values - can this be trimmed/removed?
by hdb (Monsignor) on Apr 28, 2015 at 19:00 UTC

    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}; } }