in reply to Adjacent numbers
/^(.*)_(\d+)$/ and undef $h{$1}{$2} for <DATA>; for(keys %h){ for $x (sort keys %{$h{$_}}){ if(exists $h{$_}{$x + 1} || exists $h{$_}{$x - 1}){ print "$_ : $x\n"; } } } __DATA__ 2L_33 2L_34 3L_45 3L_87 X_202 X_203 X_204 [download]