home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / save_param.al < prev    next >
Encoding:
Text File  |  2003-09-17  |  1.5 KB  |  57 lines

  1. # NOTE: Derived from blib\lib\CGI\Session.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package CGI::Session;
  5.  
  6. #line 983 "blib\lib\CGI\Session.pm (autosplit into blib\lib\auto\CGI\Session\save_param.al)"
  7. # save_param() - copies a list of third party object parameters
  8. # into CGI::Session object's '_DATA' table
  9. sub save_param {
  10.     my ($self, $cgi, $list) = @_;
  11.  
  12.     unless ( ref($cgi) ) {
  13.         confess "save_param(): first argument should be an object";
  14.  
  15.     }
  16.     unless ( $cgi->can('param') ) {
  17.         confess "save_param(): Cannot call method param() on the object";
  18.     }
  19.  
  20.     my @params = ();
  21.     if ( defined $list ) {
  22.         unless ( ref($list) eq 'ARRAY' ) {
  23.             confess "save_param(): second argument must be an arrayref";
  24.         }
  25.  
  26.         @params = @{ $list };
  27.  
  28.     } else {
  29.         @params = $cgi->param();
  30.  
  31.     }
  32.  
  33.     my $n = 0;
  34.     for ( @params ) {
  35.         # It's imporatnt to note that CGI.pm's param() returns array
  36.         # if a parameter has more values associated with it (checkboxes
  37.         # and crolling lists). So we should access its parameters in
  38.         # array context not to miss anything
  39.         my @values = $cgi->param($_);
  40.  
  41.         if ( defined $values[1] ) {
  42.             $self->_set_param($_ => \@values);
  43.  
  44.         } else {
  45.             $self->_set_param($_ => $values[0] );
  46.  
  47.         }
  48.  
  49.         ++$n;
  50.     }
  51.  
  52.     return $n;
  53. }
  54.  
  55. # end of CGI::Session::save_param
  56. 1;
  57.