Loading ...
Sorry, an error occurred while loading the content.
 

Postcode

Expand Messages
  • Shuab Muhammad
    Hello All, Does anyone know any good websites that can help me write a perl script to print a valid UK postcode ie. two letters and one number, then a space
    Message 1 of 14 , Apr 27, 2005
      Hello All,
      Does anyone know any good websites that can help me write a perl script to print a valid UK postcode ie. two letters and one number, then a space and one number and two letters.

      Cheers

      Send instant messages to your online friends http://uk.messenger.yahoo.com

      [Non-text portions of this message have been removed]
    • J.E. Cripps
      ... perldocs.perl.org
      Message 2 of 14 , Apr 27, 2005
        > Hello All,
        > Does anyone know any good websites that can help me write
        > a perl script to print a valid UK postcode ie. two letters and one
        > number, then a space and one number and two letters.


        perldocs.perl.org
      • Scot Robnett
        You don t need a web site for that info. Try: perldoc perlre in your shell or cmd window. Hey, I m a poet. Scot R inSite ... From:
        Message 3 of 14 , Apr 27, 2005
          You don't need a web site for that info.

          Try:

          perldoc perlre

          in your shell or cmd window.

          Hey, I'm a poet.

          Scot R
          inSite



          -----Original Message-----
          From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com]On
          Behalf Of Shuab Muhammad
          Sent: Wednesday, April 27, 2005 2:24 PM
          To: perl-beginner@yahoogroups.com
          Subject: [PBML] Postcode



          Hello All,
          Does anyone know any good websites that can help me write a perl script to
          print a valid UK postcode ie. two letters and one number, then a space and
          one number and two letters.

          Cheers

          Send instant messages to your online friends http://uk.messenger.yahoo.com

          [Non-text portions of this message have been removed]



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html
          Yahoo! Groups Links









          --
          No virus found in this incoming message.
          Checked by AVG Anti-Virus.
          Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 4/25/2005

          --
          No virus found in this outgoing message.
          Checked by AVG Anti-Virus.
          Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 4/25/2005
        • perlocean@hotpop.com
          ... From: Shuab Muhammad To: Sent: Wednesday, April 27, 2005 2:23 PM Subject: [PBML] Postcode ...
          Message 4 of 14 , Apr 27, 2005
            ----- Original Message -----
            From: "Shuab Muhammad" <tech20052003@...>
            To: <perl-beginner@yahoogroups.com>
            Sent: Wednesday, April 27, 2005 2:23 PM
            Subject: [PBML] Postcode


            >
            > Hello All,
            > Does anyone know any good websites that can help me write a perl script to
            > print a valid UK postcode ie. two letters and one number, then a space and
            > one number and two letters.
            >

            Yes,
            http://perlmonks.org/index.pl?node_id=449971

            > Cheers
            >
            > Send instant messages to your online friends http://uk.messenger.yahoo.com
            >
            > [Non-text portions of this message have been removed]
            >
            >
            >
            > Unsubscribing info is here:
            > http://help.yahoo.com/help/us/groups/groups-32.html
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >
          • Shuab Muhammad
            It says perldoc is not recognised when i try it in the cmd window. Scot Robnett wrote: You don t need a web site for that info. Try:
            Message 5 of 14 , Apr 28, 2005
              It says perldoc is not recognised when i try it in the cmd window.

              Scot Robnett <scot@...> wrote:
              You don't need a web site for that info.

              Try:

              perldoc perlre

              in your shell or cmd window.

              Hey, I'm a poet.

              Scot R
              inSite



              -----Original Message-----
              From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com]On
              Behalf Of Shuab Muhammad
              Sent: Wednesday, April 27, 2005 2:24 PM
              To: perl-beginner@yahoogroups.com
              Subject: [PBML] Postcode



              Hello All,
              Does anyone know any good websites that can help me write a perl script to
              print a valid UK postcode ie. two letters and one number, then a space and
              one number and two letters.

              Cheers

              Send instant messages to your online friends http://uk.messenger.yahoo.com

              [Non-text portions of this message have been removed]



              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html
              Yahoo! Groups Links









              --
              No virus found in this incoming message.
              Checked by AVG Anti-Virus.
              Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 4/25/2005

              --
              No virus found in this outgoing message.
              Checked by AVG Anti-Virus.
              Version: 7.0.308 / Virus Database: 266.10.3 - Release Date: 4/25/2005



              Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
              Yahoo! Groups Links









              Send instant messages to your online friends http://uk.messenger.yahoo.com

              [Non-text portions of this message have been removed]
            • mail meda
              Hi, Try this Regex. my $postalcode; if($postalcode =~ m/[a-zA-z][a-zA-z][0-9] s[0-9][a-zA-z][a-zA-z]/) This can validate your codes.This is just a sample. You
              Message 6 of 14 , Apr 28, 2005
                Hi,

                Try this Regex.

                my $postalcode;
                if($postalcode =~ m/[a-zA-z][a-zA-z][0-9]\s[0-9][a-zA-z][a-zA-z]/)

                This can validate your codes.This is just a sample.
                You can write in more effective way by looking at regular expressions in
                Perl.

                Regards,
                Shiva.


                On 4/28/05, perlocean@... <perlocean@...> wrote:
                >
                >
                >
                > ----- Original Message -----
                > From: "Shuab Muhammad" <tech20052003@...>
                > To: <perl-beginner@yahoogroups.com>
                > Sent: Wednesday, April 27, 2005 2:23 PM
                > Subject: [PBML] Postcode
                >
                > >
                > > Hello All,
                > > Does anyone know any good websites that can help me write a perl script
                > to
                > > print a valid UK postcode ie. two letters and one number, then a space
                > and
                > > one number and two letters.
                > >
                >
                > Yes,
                > http://perlmonks.org/index.pl?node_id=449971
                >
                > > Cheers
                > >
                > > Send instant messages to your online friends
                > http://uk.messenger.yahoo.com
                > >
                > > [Non-text portions of this message have been removed]
                > >
                > >
                > >
                > > Unsubscribing info is here:
                > > http://help.yahoo.com/help/us/groups/groups-32.html
                > > Yahoo! Groups Links
                > >
                > >
                > >
                > >
                > >
                > >
                > >
                >
                > Unsubscribing info is here:
                > http://help.yahoo.com/help/us/groups/groups-32.html
                > Yahoo! Groups Links
                >
                >
                >
                >
                >


                [Non-text portions of this message have been removed]
              • Mike Southern
                A simple perldoc perlre is insufficient as an answer. So is a simple algorithm. ... But in context any real application that is seriously validating UK
                Message 7 of 14 , Apr 28, 2005
                  A simple "perldoc perlre" is insufficient as an answer.

                  So is a simple algorithm.

                  It's easy to check standard formats using such as this:

                  > if($postalcode =~ m/[a-zA-z][a-zA-z][0-9]\s[0-9][a-zA-z][a-zA-z]/)

                  But in context any real application that is seriously validating UK
                  postcodes (or US ZIPS, or European codes) has to have complex and subjective
                  design.

                  Forexample, the code above would not validate the Cardiff postcode "CF14
                  0GA"

                  And a simple google of London Postcodes will show areas codes such as SE1 to
                  SE17, and secondary codes throught the country of more than one numeric e.g
                  SE17 12AA (example only). It's more complicated by the numbers expressed
                  simply rather than conforming to - say - double digit format (7, 8, 9, 10
                  instead of 07, 08, 09, 10).

                  So as an exercise in simple matching this code will only half work. If you
                  had a web form capturing critical address data and you needed to validate
                  accurate content rather than accurate format the code won't work at all.

                  What the intent of your design?

                  If serious validation is your intent (rather than academic study) then you
                  need to contact the UK Post Office who will (somewhere) be able to issue you
                  you with a complete list of UK postcodes against which your application
                  should check. Then the project is not one of string formatting but that of
                  data maintainence: how do you ensure that your source data from the Post
                  Office is kept up to date, for example.





                  On 4/28/05 5:57 AM, mail meda at mailmeda@... wrote:

                  > Hi,
                  >
                  > Try this Regex.
                  >
                  > my $postalcode;
                  > if($postalcode =~ m/[a-zA-z][a-zA-z][0-9]\s[0-9][a-zA-z][a-zA-z]/)
                  >
                  > This can validate your codes.This is just a sample.
                  > You can write in more effective way by looking at regular expressions in
                  > Perl.
                  >
                  > Regards,
                  > Shiva.
                  >
                  >
                  > On 4/28/05, perlocean@... <perlocean@...> wrote:
                  >>
                  >>
                  >>
                  >> ----- Original Message -----
                  >> From: "Shuab Muhammad" <tech20052003@...>
                  >> To: <perl-beginner@yahoogroups.com>
                  >> Sent: Wednesday, April 27, 2005 2:23 PM
                  >> Subject: [PBML] Postcode
                  >>
                  >>>
                  >>> Hello All,
                  >>> Does anyone know any good websites that can help me write a perl script
                  >> to
                  >>> print a valid UK postcode ie. two letters and one number, then a space
                  >> and
                  >>> one number and two letters.
                • Shuab Muhammad
                  My intent is to validate a UK style postcode with correct formatting, so if i was to enter format = U, then the postcode would return as upper case and if I
                  Message 8 of 14 , Apr 28, 2005
                    My intent is to validate a UK style postcode with correct formatting, so if i was to enter format = U, then the postcode would return as upper case and if I was to enter format = L then it would be lowercase.

                    Mike Southern <gb1198@...> wrote:A simple "perldoc perlre" is insufficient as an answer.

                    So is a simple algorithm.

                    It's easy to check standard formats using such as this:

                    > if($postalcode =~ m/[a-zA-z][a-zA-z][0-9]\s[0-9][a-zA-z][a-zA-z]/)

                    But in context any real application that is seriously validating UK
                    postcodes (or US ZIPS, or European codes) has to have complex and subjective
                    design.

                    Forexample, the code above would not validate the Cardiff postcode "CF14
                    0GA"

                    And a simple google of London Postcodes will show areas codes such as SE1 to
                    SE17, and secondary codes throught the country of more than one numeric e.g
                    SE17 12AA (example only). It's more complicated by the numbers expressed
                    simply rather than conforming to - say - double digit format (7, 8, 9, 10
                    instead of 07, 08, 09, 10).

                    So as an exercise in simple matching this code will only half work. If you
                    had a web form capturing critical address data and you needed to validate
                    accurate content rather than accurate format the code won't work at all.

                    What the intent of your design?

                    If serious validation is your intent (rather than academic study) then you
                    need to contact the UK Post Office who will (somewhere) be able to issue you
                    you with a complete list of UK postcodes against which your application
                    should check. Then the project is not one of string formatting but that of
                    data maintainence: how do you ensure that your source data from the Post
                    Office is kept up to date, for example.





                    On 4/28/05 5:57 AM, mail meda at mailmeda@... wrote:

                    > Hi,
                    >
                    > Try this Regex.
                    >
                    > my $postalcode;
                    > if($postalcode =~ m/[a-zA-z][a-zA-z][0-9]\s[0-9][a-zA-z][a-zA-z]/)
                    >
                    > This can validate your codes.This is just a sample.
                    > You can write in more effective way by looking at regular expressions in
                    > Perl.
                    >
                    > Regards,
                    > Shiva.
                    >
                    >
                    > On 4/28/05, perlocean@... <perlocean@...> wrote:
                    >>
                    >>
                    >>
                    >> ----- Original Message -----
                    >> From: "Shuab Muhammad" <tech20052003@...>
                    >> To: <perl-beginner@yahoogroups.com>
                    >> Sent: Wednesday, April 27, 2005 2:23 PM
                    >> Subject: [PBML] Postcode
                    >>
                    >>>
                    >>> Hello All,
                    >>> Does anyone know any good websites that can help me write a perl script
                    >> to
                    >>> print a valid UK postcode ie. two letters and one number, then a space
                    >> and
                    >>> one number and two letters.



                    Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



                    ---------------------------------
                    Yahoo! Groups Links

                    To visit your group on the web, go to:
                    http://groups.yahoo.com/group/perl-beginner/

                    To unsubscribe from this group, send an email to:
                    perl-beginner-unsubscribe@yahoogroups.com

                    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



                    Send instant messages to your online friends http://uk.messenger.yahoo.com

                    [Non-text portions of this message have been removed]
                  • Shuab Muhammad
                    How do i get the postcode to validate spaces and no spaces? I have done the following: #! /usr/bin/perl use strict; use CGI :standard ; #my $q = new CGI; my
                    Message 9 of 14 , Apr 29, 2005
                      How do i get the postcode to validate spaces and no spaces?

                      I have done the following:

                      #! /usr/bin/perl
                      use strict;
                      use CGI ':standard';

                      #my $q = new CGI;
                      my $postcode = param("postcode");
                      my $format = param("format");



                      print "Content-type: text/html\n\n";
                      if($postcode =~ m/([a-zA-z][a-zA-z][0-9]\s[0-9][a-zA-z][a-zA-z])/) {

                      if ($format eq "U")
                      {
                      my $postcodeU = uc("$postcode");
                      print "$postcodeU\n";
                      }

                      elsif ($format eq "L") {
                      my $postcodeL = lc ("$postcode");
                      print "$postcodeL\n";
                      }

                      elsif ($format eq "ns" ) {

                      }

                      elsif ($format eq "sp" ) {
                      }

                      }

                      else {
                      print "Invalid data\n";
                      }



                      Send instant messages to your online friends http://uk.messenger.yahoo.com

                      [Non-text portions of this message have been removed]
                    • Mike Southern
                      But UK postcodes aen t lower case, so what are you attempting to validate?
                      Message 10 of 14 , Apr 29, 2005
                        But UK postcodes aen't lower case, so what are you attempting to validate?

                        > My intent is to validate a UK style postcode with correct formatting, so if i
                        > was to enter format = U, then the postcode would return as upper case and if I
                        > was to enter format = L then it would be lowercase.
                      • Shuab Muhammad
                        Can anyone tell me why the space and no space part of this code doesnt work please? #! /usr/bin/perl use strict; use CGI :standard ; my $postcode =
                        Message 11 of 14 , May 1, 2005
                          Can anyone tell me why the "space" and "no space" part of this code doesnt work please?

                          #! /usr/bin/perl
                          use strict;
                          use CGI ':standard';
                          my $postcode = param("postcode");
                          my $format = param("format");
                          print "Content-type: text/html\n\n";
                          if($postcode =~ m/([a-zA-z]{2}[0-9]{1,2}[ ]?[0-9][a-zA-z]{2})/) {

                          if ($format eq "U")
                          {
                          my $postcodeU = uc ("$postcode");
                          print "$postcodeU\n";
                          }
                          elseif ($format eq "L")
                          {
                          my $postcodeL = lc ("$postcode");
                          print "$postcodeL\n";
                          }
                          elseif ($format eq "ns")
                          {
                          my $postcodens = ns ("$postcode");
                          print "$postcodens\n";
                          }
                          elseif ($format eq "sp")
                          {
                          my $postcodesp = sp ("$postcode");
                          print "$postcodesp\n";
                          }
                          }
                          else
                          {
                          print "Invalid data\n";
                          }

                          Send instant messages to your online friends http://uk.messenger.yahoo.com

                          [Non-text portions of this message have been removed]
                        • Mike Southern
                          Because the subroutines ns and sp appear to be undefined. (Also, it s elsif not elseif ).
                          Message 12 of 14 , May 1, 2005
                            Because the subroutines "ns" and "sp" appear to be undefined.

                            (Also, it's "elsif" not "elseif").


                            At 5/1/2005, you wrote:
                            >Can anyone tell me why the "space" and "no space" part of this code doesnt
                            >work please?
                            >
                            >#! /usr/bin/perl
                            >use strict;
                            >use CGI ':standard';
                            >my $postcode = param("postcode");
                            >my $format = param("format");
                            >print "Content-type: text/html\n\n";
                            >if($postcode =~ m/([a-zA-z]{2}[0-9]{1,2}[ ]?[0-9][a-zA-z]{2})/) {
                            >
                            >if ($format eq "U")
                            >{
                            >my $postcodeU = uc ("$postcode");
                            >print "$postcodeU\n";
                            >}
                            >elseif ($format eq "L")
                            >{
                            >my $postcodeL = lc ("$postcode");
                            >print "$postcodeL\n";
                            >}
                            >elseif ($format eq "ns")
                            >{
                            >my $postcodens = ns ("$postcode");
                            >print "$postcodens\n";
                            >}
                            >elseif ($format eq "sp")
                            >{
                            >my $postcodesp = sp ("$postcode");
                            >print "$postcodesp\n";
                            >}
                            >}
                            >else
                            >{
                            >print "Invalid data\n";
                            >}
                            >
                            >Send instant messages to your online friends http://uk.messenger.yahoo.com
                            >
                            >[Non-text portions of this message have been removed]
                            >
                            >
                            >
                            >Unsubscribing info is here:
                            >http://help.yahoo.com/help/us/groups/groups-32.html
                            >Yahoo! Groups Links
                            >
                            >
                            >
                            >
                          • Shuab Muhammad
                            Sorry yeh i knew about elsif part, I forgot to change that. About the ns and sp part, how can i define them? do you mean just put ns = no space and sp =
                            Message 13 of 14 , May 1, 2005
                              Sorry yeh i knew about "elsif" part, I forgot to change that.

                              About the "ns" and "sp" part, how can i define them?

                              do you mean just put ns = no space and sp = space sort of thing?


                              Mike Southern <gb1198@...> wrote:
                              Because the subroutines "ns" and "sp" appear to be undefined.

                              (Also, it's "elsif" not "elseif").


                              At 5/1/2005, you wrote:
                              >Can anyone tell me why the "space" and "no space" part of this code doesnt
                              >work please?
                              >
                              >#! /usr/bin/perl
                              >use strict;
                              >use CGI ':standard';
                              >my $postcode = param("postcode");
                              >my $format = param("format");
                              >print "Content-type: text/html\n\n";
                              >if($postcode =~ m/([a-zA-z]{2}[0-9]{1,2}[ ]?[0-9][a-zA-z]{2})/) {
                              >
                              >if ($format eq "U")
                              >{
                              >my $postcodeU = uc ("$postcode");
                              >print "$postcodeU\n";
                              >}
                              >elseif ($format eq "L")
                              >{
                              >my $postcodeL = lc ("$postcode");
                              >print "$postcodeL\n";
                              >}
                              >elseif ($format eq "ns")
                              >{
                              >my $postcodens = ns ("$postcode");
                              >print "$postcodens\n";
                              >}
                              >elseif ($format eq "sp")
                              >{
                              >my $postcodesp = sp ("$postcode");
                              >print "$postcodesp\n";
                              >}
                              >}
                              >else
                              >{
                              >print "Invalid data\n";
                              >}
                              >
                              >Send instant messages to your online friends http://uk.messenger.yahoo.com
                              >
                              >[Non-text portions of this message have been removed]
                              >
                              >
                              >
                              >Unsubscribing info is here:
                              >http://help.yahoo.com/help/us/groups/groups-32.html
                              >Yahoo! Groups Links
                              >
                              >
                              >
                              >



                              Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



                              ---------------------------------
                              Yahoo! Groups Links

                              To visit your group on the web, go to:
                              http://groups.yahoo.com/group/perl-beginner/

                              To unsubscribe from this group, send an email to:
                              perl-beginner-unsubscribe@yahoogroups.com

                              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                              Send instant messages to your online friends http://uk.messenger.yahoo.com

                              [Non-text portions of this message have been removed]
                            • Mike Southern
                              ... You define them to be whatever you want them to be. They are your subroutines. This code says if the value of $format is ns then use the subroutine
                              Message 14 of 14 , May 1, 2005
                                At 5/1/2005, you wrote:
                                >Sorry yeh i knew about "elsif" part, I forgot to change that.
                                >
                                >About the "ns" and "sp" part, how can i define them?
                                >
                                >do you mean just put ns = no space and sp = space sort of thing?
                                >

                                You define them to be whatever you want them to be. They are your subroutines.

                                This code says if the value of $format is "ns" then use the subroutine
                                called "ns" to process the variable called $postcode and store the results
                                in the variable called $postcodens. Then print $postcodens.

                                1: elseif ($format eq "ns") {
                                2: my $postcodens = ns ("$postcode");
                                3: print "$postcodens\n";
                                4: }

                                So if your subroutine was like this:

                                sub ns {
                                (my $t)=@_;
                                $t = "fish";
                                return $t;
                                }

                                Then your code would print "fish" at line 4.

                                I have no clue why you would want to do that, but that's why your code is
                                not working. You do not have a subroutine called "ns" or "sp".

                                I am also not clear what it is you are trying to achieve in your postcode
                                validator, therefore cannot tell what you want those subroutines to do.



                                >Mike Southern <gb1198@...> wrote:
                                >Because the subroutines "ns" and "sp" appear to be undefined.
                              Your message has been successfully submitted and would be delivered to recipients shortly.