$dirtoget = "/tmp/invs"; opendir(FILEDIR, $dirtoget) || die ("Cannot open $dirtoget"); @thefiles = grep -T, <$dirtoget/*>; #Store the filenames into an array closedir(FILEDIR); #Calling another perl script that takes each filename as argument #and splits the file into multiple files for further processing foreach $file (@thefiles) { @split_files = `perl split_invs.pl $file`) || next; chomp(@split_files); $temp = join(" ", @split_files); `/tmp/get_acct_info.sh $temp`; #This script takes each split file and reads some information & #outputs the info to the file output_acct_list.out #Load the main accounts file into a hash to compare against another file #and output accounts only in output_accts_list $origaccts = "/tmp/main_accounts.txt"; open(FILEHANDLE, $origaccts) || die ("Cannot open $origaccts"); %lookup = map {chomp; $_ => undef} ; close(FILEHANDLE); $acctlist = "/tmp/output_acct_list.out"; #Open the file output_acct_list for reading open(ACCTLISTFILE, $banlist) || die ("Cannot open $acctlist"); #Output file that will contain filename of the bills that should be loaded into our system open($output, '>', '/tmp/invs_load.txt') || die ("Cannot open output file /tmp/invs_load.txt"); while ($line = ){ chomp $line; ($filename, undef, undef, undef, $account) = split /\t/, $line; next if exists $lookup{$account}; print $output "$filename\n"; #Print the filename of bills to be loaded to invs_load.txt } }