How can I quickly find the first line of a file that matches a regex?

Posted by lamcro on Stack Overflow See other posts from Stack Overflow or by lamcro
Published on 2008-12-13T14:30:36Z Indexed on 2010/04/01 17:13 UTC
Read the original article Hit count: 246

Filed under:
|
|

I want to search for a line in a file, using regex, inside a Perl script.

Assuming it is in a system with grep installed, is it better to:

  • call the external grep through an open() command
  • open() the file directly and use a while loop and an if ($line =~ m/regex/)?

© Stack Overflow or respective owner

Related posts about perl

Related posts about grep