Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 rifling through the Monastery: (7)
As of 2015-07-05 15:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls