http://www.perlmonks.org?node_id=119780


in reply to Comma Delimitted Fields..

split the color field ($data[1]) into an array and the print the colors like so:
#!/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, $_); } # if all fields exist (gets rid of PER issue) if (($data[0]) && ($data[1]) && ($data[2])) { my @colors=split(/,/, $data[1]); print "Name = $data[0]\n"; for (@colors){ # print each color print "Color = $_\n"; } print "Date = $data[2]\n"; } }

-phill