in reply to Counting Data in two columns?

I had never seen the "=~" operator used for numeric comparison before. This is called the "binding" operator, described in perlop as follows: "binds a scalar expression to a pattern match."

So, when you do this:  if ( $v =~ 1 ) what's really happening is that the numeric "1" is being converted to a string and used as a regular expression, and the condition will be true if the current value of $v, when converted to a string, contains a digit "1". Try the following command line (may need to fiddle with the quotes, if you're using an ms-dos shell):

perl -e '$x = 213; print "got a one\n" if ($x =~ 1)'
For me, that prints "got a one". For comparing numeric values, you want:
if ( $v == 1 )
and of course, if that condition proves to be false, do you really need to test again for this condition?
elsif ( $v != 1 )