TEXT   34

how many errors

Guest on 22nd April 2022 01:12:19 AM

  1. # This code was recently posted to the PHL.pm mailing list
  2. # How many errors can you find?
  3.  
  4. ----------------------------------------------------------------
  5. I'm passing a zip through this rule:
  6.  
  7.         if(country eq 'CA' and in_range(zip, 'A1A1A1', 'S9Z9Z9') or   in_range(zip,
  8.         'X1A1A1', 'Y9Z9Z9'))",
  9.  
  10. ########################################
  11. # in_range(value, low, high)
  12. #
  13. # Returns true if $value is gt $low and lt $high using lexographic
  14. # comparison.  Returns false otherwise
  15. #
  16. ########################################
  17.  
  18. sub in_range
  19. {
  20.     my($value, $low, $high) = @_;
  21.  
  22.     return(($low lt $value) && ($value lt $high) || $value == $low || $value
  23. == $high );
  24. }

Raw Paste


Login or Register to edit or fork this paste. It's free.