in reply to querying a range of values

First, a succinct way to do this is to use the between function from Acme::Tools:
use Acme::Tools; if (between($frequency, 10, 15) {print "Yes"}
I believe your code does not print Yes due to operator precedence. My guess is that
if ($frequency == 10 .. 15) {print "Yes"}
is the same as:
if ( ($frequency == 10) .. 15 ) {print "Yes"}
in which case, the left side of the .. operator ($frequency == 10) is false, and in that case the whole expression is false. Refer to Range Operators.

Update: add another example...

If you set it to 10, you will get a Yes:

my $frequency = 10; if ($frequency == 10 .. 15) {print "Yes"}
but, you will get a warning if you use warnings; In any case, you should not try to use .. this way.

Replies are listed 'Best First'.
Re^2: querying a range of values
by jwkrahn (Abbot) on Jan 12, 2010 at 21:53 UTC

    The  .. operator in scalar context is the flip-flop operator, not the range operator.

      The .. operator in scalar context is the flip-flop operator, not the range operator.
      Firstly, I never explicitly named the .. operator in my post; I merely linked to the Perl official documentation which describes the .. operator, titled Range Operators.

      Secondly, the documentation appears to disagree with your assertion that .. in scalar context is not the range operator (emphasis is mine):

      In scalar context, ".." returns a boolean value. The operator is bistable, like a flip-flop, and emulates the line-range (comma) operator of sed, awk, and various editors. Each ".." operator maintains its own boolean state. It is false as long as its left operand is false. Once the left operand is true, the range operator stays true until the right operand is true, AFTER which the range operator becomes false again. It doesn't become false till the next time the range operator is evaluated. It can test the right operand and become false on the same evaluation it became true (as in awk), but it still returns true once. If you don't want it to test the right operand till the next evaluation, as in sed, just use three dots ("...") instead of two. In all other regards, "..." behaves just like ".." does.
      You may refer to the operator however you wish, but it is correct to refer to it as the "range operator" in all contexts, including scalar context.