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

Re: How do i search and extract commented lines from a file using perl?

by Anonymous Monk
on Jun 26, 2015 at 21:05 UTC ( [id://1132229]=note: print w/replies, xml ) Need Help??


in reply to How do i search and extract commented lines from a file using perl?

Just for fun, a quick one-liner solution using perl's "flip-flop" (range) operator.

$ cat 1132036.txt This is line 1 /*This is line 2 This is line 3 This is line 4*/ This is line 5 $ perl -ne 'print unless /\/\*/ .. /\*\//' 1132036.txt This is line 1 This is line 5

Note that like several of the other solutions presented by other monks, this doesn't fully handle the case of the comment markers appearing in the middle of the lines.

  • Comment on Re: How do i search and extract commented lines from a file using perl?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-20 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found