I figured I'd take a stab at fleshing this out into what he wants...
Any comments on things I could do better? I only added to what
Robert had coded...
Tony
#!/usr/bin/perl -w
use strict;
my $dirname = "/my/stuff/";
my $file;
my $newfile;
my $line;
opendir (DIR, $dirname) or die "Can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
next if $file =~ /^\.\.?$/;
open (OLDFILE, "< $file");
$newfile = $file . "_nice";
open (NEWFILE, "> $newfile");
while ($line = <OLDFILE>) {
($line) = ($line =~ /^\s*(.*)\s*\n$/);
print NEWFILE "$line\n";
}
close OLDFILE;
close NEWFILE;
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 8:32 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Getting rid of white space...
are you speaking of this?
use strict;
while(my $line = <>) {
($line) = ($line =~ /^\s*(.*)\s*\n$/);
print($line."_nice/n");
}
-----Original Message-----
From: LoneWolf [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 3:38 PM
To: [EMAIL PROTECTED]
Subject: Getting rid of white space...
I have about 12 files that I am pulling for a SCO box to a RedHat box, FTP.
THe files from the SCO box are poorly formatted with extraneous whitespace
(sometimes as much as 30 or more) before and after the text. I need to
parse all of the files I DL and put them into a new file with "_nice" added
at the end.
The files are all pipe-delimited, so I don't have a problem separating the
fields, I just am not sure how to make it remove all extra whitespace. It
needs to keep all Space in the fields " the description of the
file " should still be readable as "the description of the file"
Any help with code examples? I have been looking through a beginning book
and my old code and have come up nil.
Thanks,
Robert
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]