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

Re: [PBML] Postcode

Expand Messages
  • 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 1 of 14 , May 1, 2005
    • 0 Attachment
      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 2 of 14 , May 1, 2005
      • 0 Attachment
        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.