I have code:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
#Coder: pavel69
open FILE1, "/home/stackovershroom/0/28.12.txt" or die;
my %dec28;
while (my $line1=<FILE1>) {
chomp($line1);
(my $plu28, my $count28) = split / /, $line1;
$dec28{$plu28} = $count28;
}
open FILE2, "/home/stackovershroom/0/29.12.txt" or die;
my %dec29;
while (my $line2=<FILE2>) {
chomp($line2);
(my $plu29, my $count29) = split / /, $line2;
$dec29{$plu29} = $count29;
}
print Dumper \%dec28;
print Dumper \%dec29;
Output:
$VAR1 = {
'3203100' => '7',
'3467390' => '14',
'3017931' => '19',
'3312878' => '1.806',
'3362576' => '56',
'3173204' => '23',
'3335495' => '6.377',
'202' => '30.848',
'2161067' => '13',
'3356411' => '6',
'3483437' => '6',
'3359188' => '11',
'...' => '...' #yet more 500 strings!
};
$VAR1 = {
'3153446' => '89.480',
'2062513' => '9',
'3386209' => '8.379',
'3195682' => '17.266',
'3411129' => '18',
'3154498' => '4.916',
'2043226' => '12',
'...' => '...' #yet more 500 strings!
};
I want to compare two hashes for searching keys from %dec28, values of which were incremented (from %dec29).
For clarity, in %dec28 I have:
'209198' => '2'
in %dec29 I have:
'209198' => '13'
Need to get all (only) incremented values for %dec28 when compare %dec28 <=> %dec29 (Increment values contains in %dec29). I was only able to get new keys/values that occur in %dec29
Minimal example:
%dec28 = (
'3091212' => '1',
'2093334' => '74',
'209' => '5.600',
'1947754' => '3',
'3130087' => '6');
%dec29 = (
'3091212' => '4',
'2093334' => '60',
'209' => '13.844',
'1947754' => '9',
'3130087' => '6');
Need to construct new
%increment_values = (
'3091212' => '4'
'209' => '13.844'
'1947754' => '9');
It is possible? How I can do it?