#!/usr/bin/perl -w use strict; die "must have at least 2 files\n" if @ARGV <2; my ($first_file, @other_files) = @ARGV; open(IN, '<', "$first_file") || die "can't open $first_file $!"; while () { #work on each line in the first file } foreach my $file (@other_files) { open (IN, "<", $file) or die "can't open $file $!"; while () { #work on each line in the sub files } }