Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: search for a pattern in file without opening the file

by tcf03 (Deacon)
on Jan 29, 2007 at 14:44 UTC ( #597091=note: print w/ replies, xml ) Need Help??


in reply to search for a pattern in file without opening the file

If you don't want to open the files in your code you could use a system call.

my $success = ( system("grep $searchpat $file >/dev/null") ) ? 0 : 1;
as long as its a simple pattern.
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson


Comment on Re: search for a pattern in file without opening the file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://597091]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2015-07-06 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (80 votes), past polls