amarceluk has asked for the wisdom of the Perl Monks concerning the following question:
Can someone tell me why that doesn't work, or what should work? Thanks!#!/usr/bin/perl print "What file do you want to run this program on?\n"; $TheFile=<STDIN>; chomp ($TheFile); open(FILE, $TheFile) or die "Can't open $TheFile.\n"; local $/ = undef; $lines = <FILE>; close(FILE); while ($lines =~ /\n\n/) { $lines =~ s/\n\n/\n/gms; } open(FILE, ">output.txt") or die "Can't open output.txt.\n"; print FILE $lines; close FILE;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: remove blank lines with regex
by Biker (Priest) on May 21, 2002 at 13:18 UTC | |
by Joost (Canon) on May 21, 2002 at 13:35 UTC | |
by amarceluk (Beadle) on May 21, 2002 at 13:41 UTC | |
Re: remove blank lines with regex
by broquaint (Abbot) on May 21, 2002 at 12:52 UTC | |
Re: remove blank lines with regex
by jeffenstein (Hermit) on May 21, 2002 at 12:59 UTC | |
by perlplexer (Hermit) on May 21, 2002 at 13:22 UTC | |
Re: remove blank lines with regex
by arunhorne (Pilgrim) on May 21, 2002 at 14:46 UTC | |
by tadman (Prior) on May 21, 2002 at 17:56 UTC |