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;
| [reply] [d/l] |
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.
| [reply] [d/l] |
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!
| [reply] |