Hello all,
I am working on, what I imagine to be a pretty basic
problem, but am have trouble with the syntax. Here is
what I need to do:
I have a file with a list of object names. I have
another file with a list of command strings which
contain these object names. This second file contains
many command lines that may not contain the object
names I am looking for.
In other words, foreach $name in File A, search for
$name in File B. If found, write the command string
that contains $name to a new file (these are the only
commands I want to run. Here is what I have so far:

open (NAMES, "<atts.txt") || die "cannot read
atts.txt";
while (<NAMES>) {# read the names into a hash
     $names{$_} = 1;
}
open (COMS, "<commands.txt") || die "cannot read
commands.txt";  #contains the complete list of command
strings.
open (NEWCOMS, "> commstorun.txt") || die "cannot
write to commstorun"; # will contain the list of
command strings with $name in them
while (<COMS>) {
                if ($names{$_}) {
                print NEWCOMS;
                }
        }
close NAMES;
close COMS;
close NEWCOMS;


Right now it's just politey ignoring the print
command.I'm looking through the Perl Cookbook right
now, but any advice is greatly appreciated.
Jason

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to