The alphabetic comparison operators are for alphabetic comparison, the the symbol operators are for numeric comparison - just opposite of what the shell does.

Now, you might think that you can handle the situation like this:

if ($expire >= 90 && $expire <= 365 || $expire eq "never")
but there is a catch. If $expire is for instance "100 yellow ribbons", Perl will say hey, you are using $expire as a number, so I'll make it a number for you. Since it starts with 100, I'll pretent its value is 100.. This may, or may not be what you want. (With warnings on, Perl will issue a warning in this case, a warning you also get if $expire equal "never"). It's a more serious issue if the range you compare against includes 0, as a string that doesn't start with something that looks like a number will be considered to be 0 if used in numeric context.

So, write your condition as:

if ($expire =~ /^\d+$/ && $expire >= 90 && $expire <= 135 || $expire e +q "never")
You might want to modify the first clause if fractional values are to be accepted as well.

Abigail


In reply to Re: Is "N" ge 90 && le 365 or does "N" = <string>? by Abigail-II
in thread Is "N" ge 90 && le 365 or does "N" = <string>? by blink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.