Hello list,

I have two hashes that I would like to compare the values where the
keys are the same. If there are any discrepancies I would like to
print them. I have been struggling in find a solution. Below is what I
have thus far:

#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;

my $firstFile = "out.txt";
my $secFile = "outADD.txt";
my $deltaFile = "datalinkDeltas.txt";

open my $firstFH,'<',$firstFile or die "ERROR opening $firstFile: $!";
open my $secFH,'<',$secFile or die "ERROR opening $secFile: $!";
open my $deltaFH,'>',$deltaFile or die "ERROR opening $deltaFile: $!";

my %firstFile;
my %secondFile;

while (my $line = <$firstFH>) {
        my ($k,$v) = split(/\s/,$line);
        $firstFile{$k} = $v;
}

while (my $line = <$secFH>) {
        my ($k,$v) = split(/\s/,$line);
        $secondFile{$k} = $v;
}
print Dumper (\%firstFile,\%secondFile);

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to