in reply to Re^3: find common data in multiple files
in thread find common data in multiple files
I am very grateful for all the useful explanations you have provided. As you know, I am very beginner of perl, i tried to modify your provided code, because it didn't worked for me. I can see the logic for your code. But please let me ask you something. Following of your code isn't giving any output when i use it for 25 files. Please tell me how to fix it.
#!/usr/bin/env perl use strict; use warnings; use autodie; my @files = glob 'pm_1206312_in*'; my %uniq; { open my $fh, '<', shift @files; while (<$fh>) { my ($k, $v) = split; $uniq{$k} = $v; } } for my $file (@files) { my %data; open my $fh, '<', $file; while (<$fh>) { my ($k, $v) = split; $data{$k} = $v; } for (keys %uniq) { delete $uniq{$_} unless exists $data{$_} and $uniq{$_} eq $dat +a{$_}; } } printf "%s %s\n", $_, $uniq{$_} for sort keys %uniq;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: find common data in multiple files
by kcott (Archbishop) on Jan 01, 2018 at 01:01 UTC | |
|
Re^5: find common data in multiple files
by poj (Abbot) on Dec 31, 2017 at 09:18 UTC | |
by mao9856 (Sexton) on Jan 01, 2018 at 05:08 UTC | |
by AnomalousMonk (Archbishop) on Jan 01, 2018 at 05:56 UTC |