Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: text matching

by Cristoforo (Deacon)
on Jun 17, 2012 at 01:13 UTC ( #976612=note: print w/ replies, xml ) Need Help??


in reply to Re^4: text matching
in thread text matching

Here is the program using a different approach with the range operator.

#!/usr/bin/perl use strict; use warnings; while (<DATA>) { if ((my $first = /^\s*#if/) .. (my $last = /^\s*#endif/)) { #print if $first || $last; print unless /^\s*reports?/; } else { print; } }

Its a neat use of the range, ( .. ), operator.

Chris

Update: changed the first print line to more accurately perform what you needed.


Comment on Re^5: text matching
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://976612]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-10-24 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls