my %saw; @out = grep {!$saw{$_}++} map {substr $_, 0, index($_,"\0")} @array;