On Tuesday, May 14, 2002, at 02:35 , Jaishree Rangaraj wrote: [..] > I have to check if a literal is within a partiocular range say [1..10].
the first thing you will need to check is that it is numeric then you can check that it is in range. > How do I do this. Can I use "eq" operator to check if it is in a > particular range 'eq' is a string compare - and that is not what you will really want to do numerical comparisons. http://www.wetware.com/drieux/pbl/perlTrick/RangeChecker.txt shows you felix's idea on how to do wider ranges of numerical checking - and is one cool solution. > for eg. > > if ($s_field eq [1..10]) { > > stmt 1; or how do i use this. Please help. please don't laugh at my > program. > > } [..] Tim's basic proposition was ok, once one had resolved that it was numbers all the way across.... so Another Strategy would be something like: http://www.wetware.com/drieux/pbl/perlTrick/RangeCheckForNumerics.txt Then you can have the basic test if ( RangeCheck($s_field, 1, 10) ){ # do the it is ok }else{ # this $s_field Is Not in range. } Hope that helps.... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]