I can't get your implementation to work . . .
What about s/^\s+|\s+$//g ? shouldn't it be s/(^\s+)|(\s+$)//g ?
And why the if in:
$_ = "\"$_\"" if ( $_ =~ /[,"]/ );
aren't you trying to keep that trailing comma off - I don't see where you
add the comma.
Tim
______________________________________________________________________
you said . . .
I would do something like this. ( I am not sure how efficient is this though
).
open( INFILE, 'in.txt' ) or die;
open( OUTFILE, '>out.txt' ) or die;
while ( <INFILE> )
{
s/^\s+|\s+$//g; # Eat leading & trailing spaces
next unless $_; # Skip empty lines
my @fields = split /\s+/;
foreach (@fields)
{
s/"/""/g;
$_ = "\"$_\"" if ( $_ =~ /[,"]/ );
}
print OUTFILE join( ',', @fields ), "\n";
}
close INFILE;
close OUTFILE;
RE: another easy question (actually 3)
Booher Timothy B 1stLt AFRL/MNAC Thu, 03 Jan 2002 15:51:53 -0800
- another easy question (actually 3) Booher Timothy B 1stLt AFRL/MNAC
- Re: another easy question (actually ... Curtis Poe
- RE: another easy question (actually ... SathishDuraisamy
- RE: another easy question (actually ... SathishDuraisamy
- RE: another easy question (actually ... SathishDuraisamy
- RE: another easy question (actua... Curtis Poe
- Booher Timothy B 1stLt AFRL/MNAC
