my @files = undef; #list of files to run script on while(my $line = ){ chomp($line); push @files, $line; }