in reply to Re^3: regex basics
in thread regex basics
Thanks! That worked perfectly. The only change I made was to remove the log. the original file remains intact for reference so a log really isn't necessary.
while (<$IN>) { if (!/;\s+/) { $text .= $_; } } ... $text =~ s{\n{2,}}{\n}gm;$
Interestingly, this is what I was reaching for. I was thinking "two passes" were needed... but the file was already open. So dump only lines of interest into a string and use a second regex operation to remove blank lines.
I like the use of curly braces for search/replace--easier to read. But I'll need to take a closer look at the .= operator (I assume it's similar to += in C#)
|
|---|