Adam Turoff on Wed, 20 Feb 2002 11:36:24 -0500 |
----- Forwarded message ----- To: "William G. Zappasodi" <bz@CrestecDigital.com> Cc: phl@lists.pm.org From: mjd-per-pm@plover.com Subject: Re: help! (fwd) In-reply-to: Your message of "Wed, 20 Feb 2002 11:16:02 EST." <20020220161602.GB8993@panix.com> Date: Wed, 20 Feb 2002 11:33:31 -0500 Sender: mjd@plover.com > Can anyone help please. I have a routine that is supposed to capture a zip > code if it falls in a range. It works fine with US zips, but not Canadian. > Seems to capture any range for CA. You have a lot of bugs here. One is that you have 'zip' where you should have '$zip'. maybe that's your main problem. Another problem you have is that you're going to reject Canadian postal codes that are in Alberta or British Columbia, since they begin with T and V, and you don't accept that. A big problem is that in_range() is totally inappropriate for Canadian postal codes anyway. For example, in_range($zip, 'A1A1A1', 'S9Z9Z9') will succeed when $zip is 'A1Z!$&', but this is not a valid Canadian postal code. I strongly recommend that you abandon this approach completely, and use: if ($country eq CA && $zip =~ /^ [ABCEGHJKLMNPRSTVXY] \d [ABCEGHJKLMNPRSTVWXYZ] \s+ \d [ABCEGHJKLMNPRSTVWXYZ] \d $/x) { # postal code is good } Note that this requires a space between the two halves of the code; according to Canada Post, this space is mandatory. To make it optional, change \s+ to \s*. I hope this is helpful. ----- End forwarded message ----- **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|