Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 studying the Monastery: (9)
As of 2014-12-26 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls