in reply to Re^2: 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

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
  • Comment on Re^3: Match pattern per line and after another one as multiline in single file opening
  • Download Code

Replies are listed 'Best First'.
Re^4: Match pattern per line and after another one as multiline in single file opening
by kennethk (Abbot) on Feb 15, 2017 at 16:30 UTC
    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.

Re^4: Match pattern per line and after another one as multiline in single file opening
by Yakup (Novice) on Dec 03, 2018 at 13:14 UTC
    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!