Okay, say this is basicdez.dat file.
"PER" "Denise Johnson" "red,orange,yellow,green,blue,purple" 09/25/2001 "EOS"
And this is the desired outcome...
Name = Denise Johnson Color = red Color = orange Color = yellow Color = green Color = blue Color = purple Date = 09/25/2001
How could I change this code to read in the colors as an array. I do not want this...
Name = Denise Johnson Color = red,orange,yellow,green,blue,purple Date = 09/25/2001
And I do not want this, which is what this code currently produces...
Name = PER Color = Date = Name = Denise Johnson Color = red,orange,yellow,green,blue,purple Date = 09/25/2001
I would like to take the colors in as a comma delimitted field and produce them out as individual fields. Please help me if you can. peace dez L Current Code (It really needs some help)
#!/usr/bin/perl-Tw use strict; use Text::ParseWords; open(DATA,"basicdez.dat") || die "Cannot open datfile: $!\n"; my @data; my $i = 0; while (<DATA>) { chomp; last if /^"EOS"$/; { @data = &quotewords('\s+', 0, $_); } print "Name = $data[0]\n"; print "Color = $data[1]\n"; print "Date = $data[2]\n"; }
I know that this does not come close, but please help me out if you can... What I really need help with is seperating out the comma dilemmeted field. Any suggestions would be awesome... dez L

In reply to Comma Delimitted Fields.. by basicdez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.