#!/usr/bin/perl use strict; my $i; my $data; open(DATA," basicdez.dat") || die "Cannot open datfile: $!\n"; # this entire loop is pointless. its almost never a good # idea to read an entire file into a single string, unless # you are going to be spitting it right back out. while(){ chomp; unless ($_=~ /"EOS"/){ $data .= "$_"; } elsif ($i ne 1) { $data .="\n"; } if ($_=~ /"EOS"/){ $i=1; } } close(DATA); my @data=split(/\n/, $data); # i find it odd that although you name every element of your # list, you don't name the loop variable. Either do one, or # both. Be consistant! for(@data){ my($first_name,$last_name,$address,$city,$state,$phone)=split; print "$first_name,$last_name\n"; print "$address\n"; print "$city, $state\n"; print "$phone \n"; } # not needed exit;