#!/usr/local/perl $sep = ";"; @add = (); print STDOUT "name${sep}careof${sep}street1${sep}street2${sep}street3${sep}city${sep}state${sep}zip${sep}country\n"; while (<>) { if ($_ !~ /^\n$/) { push(@add, $_); } else { $name = shift @add; $name =~ s/^\s*(.+?)\s*$/\1/; $name =~ s/\s+/ /g; $careof = ($add[0] =~ /c\/o/i) ? shift @add : ""; $careof =~ s/^\s*(.+?)\s*$/\1/; $careof =~ s/\s+/ /g; $street1 = ($add[0] !~ /\d{5}(-\d{4})?\s*$/) ? shift @add : ""; $street1 =~ s/^\s*(.+?)\s*$/\1/; $street1 =~ s/\s+/ /g; $street2 = ($add[0] !~ /\d{5}(-\d{4})?\s*$/) ? shift @add : ""; $street2 =~ s/^\s*(.+?)\s*$/\1/; $street2 =~ s/\s+/ /g; $street3 = ($add[0] !~ /\d{5}(-\d{4})?\s*$/) ? shift @add : ""; $street3 =~ s/^\s*(.+?)\s*$/\1/; $street3 =~ s/\s+/ /g; $add[0] =~ /^\s*(.+),\s*(.+?)\s+(\d{5}(-\d{4})?)\s*$/; $city = $1; $state = $2; $zip = $3; $city =~ s/\s*$//; shift @add; $country = ($#add >= 0) ? shift @add : ""; $country =~ s/^\s*(.+?)\s*$/\1/; $country =~ s/\s+/ /g; print STDOUT "${name}${sep}${careof}${sep}${street1}${sep}${street2}${sep}${street3}${sep}${city}${sep}${state}${sep}${zip}${sep}${country}\n"; @add = (); } }