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