foreach my $line (@data_file) { if ($line =~ m!^(\d+)\s+(([A-Za-z]+\s+[A-Za-z].\s+[A-Za-z]+)|([A-Za-z]+\s+[A-Za-z]+) )!) { print "$1 - $2 \n"; $custNum = $1; # First number field. $custName = $2; # Name styles can vary so match everything between two numbers. $custStreet = $3; # Street is everything after name and before CITY. $custCity = $4; # City is after address and before the TWO char state identifier. $custState = $5; # State is after address and before FIVE digit zip number. $custZip = $6; # Zip is before telephone number and after State id. $custTel = $7; # Telephone no. is after zip and before comments field. $custComments = $8; # Last remaining part after telephone number. } }