#!perl -w use strict; my %seen; sub intersect { # see perlfaq4 }; my $first_file = shift @ARGV; my @common = read_file($first_file); for (@ARGV) { @common = intersect( \@common, [ read_file $_ ] ); }; print "$_\n" for @common;