On Thu, Nov 01, 2012 at 12:44:08AM -0700, Thomas Smith wrote: > Hi, > > I'm trying to search a file for several matching blocks of text. A sample > of what I'm searching through is below. > > What I want to do is match "##### START block #####" through to the next > "##### END block #####" and repeat that throughout the file without > matching any of the text that falls between each matched block (that is, > the "ok: some text" lines should not be matched). Here is the one-liner I'm > using: > > perl -p -e '/^##### START block #####.*##### END block #####$/s' file.txt > > I've tried a few variations of this but with the same result--a match is > being made from the first "##### START block #####" to the last "##### END > block #####", and everything in between... I believe that the ".*", > combined with the "s" modifier, in the regex is causing this match to be > made. > > What I'm not sure how to do is tell Perl to search from START to the next > END and then start the search pattern over again with the next START-END > match. > > How might I go about achieving this?
perl -ne 'print if /##### START block #####/ .. /##### END block #####/' file.txt -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/