There are two differences between the two pieces of code.
Firstly, as others have pointed out already, there is the issue of the numeric comparison operator.
But secondly, /$dn/ checks to see if $_ contains the data in $dn. $_ eq $dn checks if $_ is exactly equal to $dn.
This difference could cause a problem, for example, if your data consisted of lines read from a file that hadn't been chomped to remove the newline.