sub param in CGI.pm

K

Keith Keller

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

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

- --
(e-mail address removed)-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-----
 
H

hudson

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];
}
 
H

hudson

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top