sub param in CGI.pm

Discussion in 'Perl Misc' started by Keith Keller, Aug 20, 2003.

  1. Keith Keller

    Keith Keller Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    In article <>, hudson wrote:
    > OK...I dug up the subroutine called param in CGI.pm. Anyone care to give me a little insight into it?


    What sort of insight are you seeking? Specific questions about lines
    of code would be more helpful. (Followup your original post if
    you want to do that.)

    - --keith

    - --
    -francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.0.6 (GNU/Linux)
    Comment: For info see http://www.gnupg.org

    iEYEARECAAYFAj9CwqYACgkQhVcNCxZ5ID/flQCeP7jQBKbHxlYNxlNeGku7WPgH
    qA4Anja5tX5BRpbpkpafNkEX7vjTYsC+
    =fUeq
    -----END PGP SIGNATURE-----
     
    Keith Keller, Aug 20, 2003
    #1
    1. Advertising

  2. Keith Keller

    hudson Guest

    OK...I dug up the subroutine called param in CGI.pm. Anyone care to give me a little insight into it?

    sub param {
    my($self,@p) = self_or_default(@_);
    return $self->all_parameters unless @p;
    my($name,$value,@other);

    # For compatibility between old calling style and use_named_parameters() style,
    # we have to special case for a single parameter present.
    if (@p > 1) {
    ($name,$value,@other) = rearrange([NAME,[DEFAULT,VALUE,VALUES]],@p);
    my(@values);

    if (substr($p[0],0,1) eq '-') {
    @values = defined($value) ? (ref($value) && ref($value) eq 'ARRAY' ? @{$value} : $value) : ();
    } else {
    foreach ($value,@other) {
    push(@values,$_) if defined($_);
    }
    }
    # If values is provided, then we set it.
    if (@values) {
    $self->add_parameter($name);
    $self->{$name}=[@values];
    }
    } else {
    $name = $p[0];
    }

    return unless defined($name) && $self->{$name};
    return wantarray ? @{$self->{$name}} : $self->{$name}->[0];
    }
     
    hudson, Aug 20, 2003
    #2
    1. Advertising

  3. Keith Keller

    hudson Guest

    On Tue, 19 Aug 2003 17:36:55 -0700, Keith Keller
    <-francisco.ca.us> wrote:

    >What sort of insight are you seeking? Specific questions about lines
    >of code would be more helpful. (Followup your original post if
    >you want to do that.)


    ahh well...maybe you are right and I am asking other people to do work
    for me....sorry about that

    to explain the post better, though, people here have told me many
    times I can't live without CGI.pm ....so I would like to know exactly
    what that module does that I can't understand.

    anyway, you are right...I really should read the code myself for a
    week or a month and come back later with specific questions instead of
    asking for a general walkthrough right off the bat
     
    hudson, Aug 20, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geathaa
    Replies:
    2
    Views:
    700
    Geathaa
    Jul 30, 2003
  2. ectoplasm
    Replies:
    12
    Views:
    646
    Zorro
    Jul 28, 2005
  3. Ben
    Replies:
    2
    Views:
    905
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,051
    Lawrence D'Oliveiro
    May 20, 2011
  5. shumsta
    Replies:
    1
    Views:
    274
    Fabian Pilkowski
    Jul 22, 2005
Loading...

Share This Page