in reply to read multiple files

Since you want to use the filename as part of individual file processing, I suggest something like the following:
use strict; use warnings; my @files = `ls *.txt`; my %filedata; foreach my $file (@files) open (CUR, $file) || die "could not open $file: $!"; my @lines = <CUR>; $filedata{$file} = \@lines; close CUR; }
I wasn't sure from your question whether you wanted to eliminate duplicate lines from files or not, and if so, dups that appeared only in all files, or just multiple files. That exercise is left to the user...