#!/usr/bin/env perl use strict; use warnings; use autodie; use Data::Dump; my @files = qw{ pm_1227048_raw_1 pm_1227048_raw_2 pm_1227048_raw_3 }; my %trio; for my $file (@files) { open my $fh, '<', $file; while (<$fh>) { chomp; my ($k, $v) = split / => /; push @{$trio{$k}}, $v; } } # This step for demonstration purposes only print "All data:\n"; dd \%trio; # Extra step due to poor input print "Data with 2 or more values:\n"; delete @trio{grep @{$trio{$_}} < 2, keys %trio}; dd \%trio; # Only this step required with better input print "Data with 3 or more values:\n"; delete @trio{grep @{$trio{$_}} < 3, keys %trio}; dd \%trio;