in reply to Re: how to search for a string in a particular file?
in thread how to search for a string in a particular file?
I did this so, but only works when file is in one line
# file.txt # one two three four five six seven eight nine ten # zero #!/usr/bin/perl use warnings; open(FILE, "file.txt"); $_ = <FILE>; close(FILE); if ($_ =~ /nine/) { print "found\n" } else { print "not found\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to search for a string in a particular file?
by tm86 (Initiate) on May 29, 2012 at 13:48 UTC |