Hi,

Just to add a hash option (assuming you have 2 files ), you will need to
customise the regex; untested:

__START__
open (FILE_A,$ARGV[0]) or die;
open (FILE_B,$ARGV[1]) or die;

while ( <FILE_A> ) {
        if ( /^(\S+)\s/ ) {
                $A{$1}++;
        }
}
close(FILE_A);

while ( <FILE_B> ) {
        if ( /^(\S+)\s/  ) {
                print "yes found it" if ( defined $A{$1} );
        } else {
                print "not found\n";
        }
}
close(FILE_B);

__END__


=====================================================================
Matt O'neill wrote:

> hi yeah, i have started to write the code but am having troubles with the
> various operators around the search bit, anyway here goes:
>
> my ($file_name, $search_string) = @ARGV;
>
> open(INFILE, "< $file_name");
>
> while (<INFILE>) {
>
> if ($_ =~ $search_string) {
>
> print "yes\n";
>
> exit();
>
> }
>
> }
>
> print "no\n";
>
> Thanks for your help
>
> "R. Joseph Newton" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Matt O'neill wrote:
> >
> > > Hi guys,
> > >
> > > I need a very simple command line perl program that takes two
> arguements,
> > > the frist being a filename and the second being a word to be searched
> for in
> > > that file.  Then I simply want the result to print "yes" if arg2 is
> found,
> > > or "no" if it is not.
> > >
> > > Thanks for your help
> > >
> > > matt.
> >
> > Hi Matt,
> >
> > It's great to hear that you are getting started in your programming
> studies!  When you get your script written, and test it by trying to run it,
> write back with the code and the results.  You will find many people happy
> to help you move forward in your efforts.
> >
> > Joseph
> >
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to