In my code I am using grep successfully, but I would also like an output file that has the objects that don't match the grep. I am trying to capture the $line of my <INFILE> that don't match. I am thinking something like if ([EMAIL PROTECTED] = grep/\b$line\b/i,@mhsArray) { } #!/usr/bin/perl use warnings;
$file="/adsm/CRONJOBS/MHS/nodes_cleanedup"; $mhs="/adsm/CRONJOBS/MHS/mh_alloc.csv"; $file_out="/adsm/CRONJOBS/MHS/in_mhs"; open (INFILE, "<", "$file") or die "$file could not be opened: $!"; open (MHSFILE, "<", "$mhs") or die "$mhs could not be opened: $!"; open (OUTFILE, ">", "$file_out") or die "$file_out could not be opened: $!"; while (<MHSFILE>) { chomp($_); push (@mhsArray, $_); } while ($line= <INFILE>) { chomp($line); print "$line\n"; @inmhs = grep/\b$line\b/i,@mhsArray; foreach $line (@inmhs) { print OUTFILE "$line\n"; } } #end while close(INFILE); close(MHSFILE); -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. --------------------------------------------------------