/[A-Z]{2,}/ #### /([A-Z]{2,})\s+([A-Z]{2,})/ #### if (exists $ids{JON_DOE}) { # found it, use old s/JON DOE/$ids{JON_DOE}; } else { # create new $ids{JON_DOE} = "UNIQUEID_$i"; $i++; }