basicdez has asked for the wisdom of the Perl Monks concerning the following question:
And this is the desired outcome..."PER" "Denise Johnson" "red,orange,yellow,green,blue,purple" 09/25/2001 "EOS"
How could I change this code to read in the colors as an array. I do not want this...Name = Denise Johnson Color = red Color = orange Color = yellow Color = green Color = blue Color = purple Date = 09/25/2001
And I do not want this, which is what this code currently produces...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)Name = PER Color = Date = Name = Denise Johnson Color = red,orange,yellow,green,blue,purple Date = 09/25/2001
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#!/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 = "ewords('\s+', 0, $_); } print "Name = $data[0]\n"; print "Color = $data[1]\n"; print "Date = $data[2]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comma Delimitted Fields..
by thatguy (Parson) on Oct 18, 2001 at 23:53 UTC | |
by Hofmator (Curate) on Oct 19, 2001 at 18:06 UTC | |
|
Re: Comma Delimitted Fields..
by Masem (Monsignor) on Oct 18, 2001 at 23:54 UTC | |
|
Re: Comma Delimitted Fields..
by scain (Curate) on Oct 19, 2001 at 00:01 UTC | |
|
Re: Comma Delimitted Fields..
by dragonchild (Archbishop) on Oct 19, 2001 at 00:01 UTC |