pyro.699 has asked for the wisdom of the Perl Monks concerning the following question:
sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; }
And i would like it to look like this:This is a line. :O and this is another line. This line is a bit more of a loner, because hes 2 lines away.
So, basically all it does, is reads the file and removes all blank lines. (some of these lines have spaces and indents on them, it should first clear those out :)) This is what i have so far:This is a line. :O and this is another line. This line is a bit more of a loner, because hes 2 lines away.
Thanks a ton guys :) ~Cody Woolaveropendir(DIR, "."); for $file (glob("*.shtml")) { $line = ""; $file_data = ""; open(FILE, $file); my @data = <FILE>; foreach my $line (@data) { #Work to be done on each line of the file $file_data .= $line; #rebuild file } open (WRITE_FILE, ">$file"); print WRITE_FILE $file_data; close WRITE_FILE; close FILE; print "Processing... ".$file."... Done!\n"; } close DIR;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing white-lines...
by kyle (Abbot) on Apr 06, 2007 at 02:35 UTC | |
|
Re: Removing white-lines...
by bobf (Monsignor) on Apr 06, 2007 at 02:41 UTC | |
|
Re: Removing white-lines...
by saintly (Scribe) on Apr 06, 2007 at 02:35 UTC | |
by ikegami (Patriarch) on Apr 07, 2007 at 06:41 UTC | |
|
Re: Removing white-lines...
by f00li5h (Chaplain) on Apr 06, 2007 at 03:02 UTC | |
|
Re: Removing white-lines...
by osunderdog (Deacon) on Apr 06, 2007 at 10:51 UTC |