--- [EMAIL PROTECTED] wrote:
> > Curtis,
> > I couldn't find this module in my standard PERL lib path. I guess I
> should get this from cpan.org. Right?
> > [sathish]
Yes. You can get it from the mirror
http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?dist=Text-CSV_XS-0.23
Note that this i
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
__
Timothy,
I'd use a proper module for something like this. CSV data can get tricky,
so see if you can
install Text::CSV_XS. Here's some sample code:
use strict;
use Text::CSV_XS;
> Curtis,
> I couldn't find this module in my standard PERL lib path. I guess I
should get this from c
--- Booher Timothy B 1stLt AFRL/MNAC <[EMAIL PROTECTED]> wrote:
> o.k. here is another one:
>
> I still have a text file I am trying to get into a csv line, for example:
>
> cheese olives beans carrots
>
> So I put this into an array like:
>
> my @heade
But now I want to print this in csv format:
"cheese","olives","beans","carrots".
> Be careful. The CSV formated line can get trickier if it
> already contains a comma or a double-quote. For example,
> the line
> chee,se oli"ves beans carrots
> should be translated to
> "chee,se","oli""ves",b
I find that I get a zero-length field for $headers[0] and don't
understand why.
Trim the leading and trailing spaces, like this:
s/^\s+|\s+$//g;
Lastly, does /\s+/ mean 2 or more spaces or does it mean one or more spaces,
'+' "means one or more"; '*' means "zero or more"; They are post-fix.
o.k. here is another one:
I still have a text file I am trying to get into a csv line, for example:
cheese olives beans carrots
So I put this into an array like:
my @headers = split /\s+/;
But now I want to print this in csv format:
"cheese","olives","