foreach my $file (@ARGV){ # check it exists.. die "$file does not exists!" unless -e $file; print "start processing $file\n"; # send the file to your own sub for processing my_custom_process_sub($file); ...