Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Match pattern per line and after another one as multiline in single file opening

by kennethk (Abbot)
on Feb 14, 2017 at 23:44 UTC ( [id://1182032]=note: print w/replies, xml ) Need Help??


in reply to Re: Match pattern per line and after another one as multiline in single file opening
in thread Match pattern per line and after another one as multiline in single file opening

Not to be a broken record, but Re^2: Match pattern per line and after another one as multiline in single file opening:
I read the description as he needs the [^}] to match through newlines, and so there needs to be a slurp before the regex. But your point about lack of test real data is very appropriate.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

  • Comment on Re^2: Match pattern per line and after another one as multiline in single file opening
  • Download Code

Replies are listed 'Best First'.
Re^3: Match pattern per line and after another one as multiline in single file opening
by BillKSmith (Monsignor) on Feb 15, 2017 at 02:42 UTC
    In that view, I would use only the OP's second program. All comments can be removed with a single substitution: $data =~ s/^\s*#.*?\n//msg;
    Bill
      I agree, though his regex also stripped empty lines, so maybe $data =~ s/^(?:\s*#.*)?\n//mg;

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      I know it is almost two years after, but I just want to thank you all for your suggestions. I wasn't visiting this site often in the meantime, as I have spent time on project with a strong preference for python. I think my Perl code wasn't used at the end. I remember that the original file was dhcp configuration file at RHEL5, but I don't remember what data exactly I was trying to extract at the time. Once again thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-20 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found