my %data; while (<>) { my $net = (split ' ')[0]; push @{$data{$net}}, $_; } foreach my $group (values %data) { if (@$group > 1) { print @$group; } }