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