Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Like everyone else, I'm not sure I understand the question.

But I think what you mean is "I want to start printing when I see regex 1, and stop printing when I see regex 2"... (Edit: Aha, looking at your 2nd post, that does seem to be what you want)

If so, here goes:

perl -i.bak -ne'if(/whateverStartRegexIs/){$print{$ARGV}=1} if(/whatev +erEndRegexIs/){$print{$ARGV}=0;} print if $print{$ARGV};' *.html
Now, if start regex and end regex match on the same line, this won't print at all. You have to figure out if that's what you want or not.

Also, if you have start...end...start...end in the same file, this will print two sets of lines for a given file. If that's not what you want, you could add a %done hash keyed on $ARGV as well...

Hope this helps!
--
Mike


In reply to Re: I'm looking for a one-liner filter 'twixt two regexes by RMGir
in thread I'm looking for a one-liner filter 'twixt two regexes by msemtd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-18 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found