#!/usr/bin/perl-Tw use strict; use Text::ParseWords; open(DATA,"CommaSample.dat") || die "Cannot open datfile: $!\n"; my @data; my $i = 0; my $new_record = 0; while () { chomp; last if /^"EOS"$/; { @data = "ewords('\s+', 0, $_); } if (/^PER\s*$/) { @data = "ewords('\s+', 0, $_); my @colors=split(/,/, $data[2]); print "Entity = $data[0]\n"; print "Name = $data[1]\n"; for (@colors) { # print each color print "Color = $_ \n"; } print "Date = $data[3]\n"; @data = "ewords ('\s+', 0, $_); } elsif (/^EMP\s*$/) { @data = "ewords('\s+', 0, $_); print "Entity = $data[0]\n"; print "Employment = $data[1]\n"; print "Job Title = $data[2]\n"; print "Hire Date = $data[3]\n"; print "Location = $data[4], $data[5] $data[6]\n"; print "Salary = $data[7]\n"; } }