Matt, The first thing to consider is better indenting. Most editors (vim, emacs, etc.) can do this automagically for you. Here's your exact code, slightly reformatted:
my ($file_name, $search_string) = @ARGV; open(INFILE, "< $file_name"); while (<INFILE>) { if ($_ =~ $search_string) { print "yes\n"; exit(); } } print "no\n"; The problem that you're having is that "$_ =~ $search_string" is missing something: what that =~ operator should do! Try changing that to "$_ =~ m/$search_string/" and you should be good. -------------------------- David Olbersen iGuard Engineer 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 > -----Original Message----- > From: Matt O'neill [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 25, 2003 8:11 AM > To: [EMAIL PROTECTED] > Subject: Re: Simple perl program > > > 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]