# Rewritten $prop->{'address'} = # reassemble the address join ' ', map { s/^(#.+)/\U$1/; # for units, such as #A or #215-C s/^(#?)0+([1-9]\S+)/$1$2/; # correct numbering, like 0000048th -> 48th s/^(mc|o')(.+$)/\u\L$1\E\u\L$2/i; # correct casing of O'Brien, McDonald, etc. s/\.+$//g; # remove literal dots at the end of elements. $_ # required at end of map when used like this } map { ucfirst lc $_ } # proper case words, simple split ' ', $prop->{'address'}; # split on spaces # Normalize street suffixes to standard postal abbreviations # This is easier than creating a temp array. $prop->{'address'} =~ s/ (\w+)$ / if (defined $street_suf_lkup{lc $1}) { $street_suf_lkup{lc $1} } else { $1 } /ex;