in reply to Comparing two files
I don't know exactly where your problem is; but if I had to do that, I might write it like this, using a module to parse the CSV:
use IO::File; my %old = map { $_->[1] => $_->[0] } map { chomp; [ split /,\s*/ ] } IO::File->new("<$file_old")->getlines; use Tie::Handle::CSV; my %new = map { ( $_->{'CN'} => $_ ) } map { { map { /(.*)=(.*)/ } split /\.(?=[A-Z]+=)/, $_->[3] } } Tie::Handle::CSV->new($file_new,header=>0)->getlines; # now %old and %new are keyed by PC ID. # you can use the standard techniques for finding keys that # are in one but not the other, e.g. my @new_PCs = grep { not exists $old{$_} } sort keys %new;
|
|---|