indapa has asked for the wisdom of the Perl Monks concerning the following question:
I would like to remove the blank lines btwn each record. I am trying the following code to do that:1 1 Foo Bar Baz <blank line> 1 1 Foo Bar Baz
I run the script with no errors, but when I look and see if the blank lines have been removed from the .txt file, there is no change. I have been trying debugging statements to see if the regex does indeed match, and it does. But the substitution does not seem to be working. It seems like an easy problem to fix, but I'm not gettting anywhere with it. Thank you.while (<FILE>) { if (/(^$)/) { s/$1//; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: replacing blank lines
by OeufMayo (Curate) on Mar 06, 2001 at 01:28 UTC | |
Re: replacing blank lines
by Tuna (Friar) on Mar 06, 2001 at 01:54 UTC | |
Re: replacing blank lines
by Anonymous Monk on Mar 06, 2001 at 04:46 UTC | |
by KM (Priest) on Mar 06, 2001 at 05:03 UTC | |
by merlyn (Sage) on Mar 06, 2001 at 05:39 UTC | |
by chipmunk (Parson) on Mar 06, 2001 at 08:20 UTC | |
Re: replacing blank lines
by Fingo (Monk) on Mar 06, 2001 at 01:49 UTC | |
Re: replacing blank lines
by kleinbiker7 (Sexton) on Mar 06, 2001 at 05:27 UTC | |
by KM (Priest) on Mar 06, 2001 at 05:36 UTC |