in reply to Searching log file by %%%


You can read the records one at a time by setting the input record separator $/ to %%%. See $/ in perlvar:
#!/usr/bin/perl -wl $/ = "%%%"; while (<DATA>) { chomp; print if /Email/; # Change to suit } __DATA__ Name: name Phone: number Fax: number Address: address Email: email address Info: information %%% Name: name Phone: number Fax: number Address: address Email: email address Info: information

--
John.

Replies are listed 'Best First'.
Re: Re: Searching log file by %%%
by Anonymous Monk on May 19, 2004 at 02:48 UTC
    Thank you for that, that helps a lot. Can you help me figure out how to search just a specific chunk of this? Instead of matching /Email/ anywhere in there, say we just want to match it in one place. A better example would be "brown cow". I just want to find this following Info: , if it follows Email or Address or anything else, it ignores it. Is there any easy way to do this simply?
      Do a regex of substr-search for Info: brown cow.

      Email: brown cow or others will not match.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law