Eric Roode on Wed, 20 Feb 2002 11:29:55 -0500 |
Adam Turoff writes: > I'm passing a zip through this rule: > if(country eq 'CA' and in_range(zip, 'A1A1A1', 'S9Z9Z9') or in_range(zip, > 'X1A1A1', 'Y9Z9Z9'))", > > The Sub is as follows: > sub in_range > { > my($value, $low, $high) = @_; > > return(($low lt $value) && ($value lt $high) || $value == $low || $value > == $high ); > } 1. '==' is used for numeric comparisons. You want 'eq'. 2. You can simplify the expression by using 'le': return ($low le $value) && ($value le $high); 3. You're not comparing the codes letter-by-letter, only within a lexical range. So: in_range('B', 'A1A1A1', 'S9Z9Z9'); in_range('B&^#@%3', 'A1A1A1', 'S9Z9Z9'); in_range('B0Z0Z0', 'A1A1A1', 'S9Z9Z9'); will all return true. Is that what you want? ---------------------------------------------------------------------- Eric J. Roode eric@myxa.com Senior Software Engineer, Myxa Corporation perl -lpe "(($0 =~ '/' ? ($_ = $0 ) =~ s!\.?/!?$!:$@;~~@@~~~NO CARRIER **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|