Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Don't ask to ask, just ask

Comment on

How about a different approach?
#!/usr/bin/perl use strict; use warnings; my ($start, $stop) = (qr '#ifdef|#if defined', qr '#endif'); open INPUT, '<', 'monks23.dat' or die "Error opening input: " . $!; while (<INPUT>) { if (/$start/ .. /$stop/) { # Print the lines themselves if (/$start/ or /$stop/) { print; } # Skip the rest next; } print; } close INPUT;
Glad I've finally found a useful non-numeric-iterating purpose for .. :)
Edit: Added comments, removed unnecessary regex escaping

In reply to Re: Text matching repost by Neighbour
in thread Text matching repost by prassi

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (2)
    As of 2014-03-15 08:56 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (318 votes), past polls