SPUG: Re: perl2exe perl-cgi file size problem

Ken Clarke kenslinux at shaw.ca
Thu May 2 14:12:30 CDT 2002


----- Original Message -----
From: "Meryll Larkin" <humbaba9 at yahoo.com>
To: "SPUG List" <spug-list at pm.org>
Sent: May 2, 2002 10:23 AM
Subject: SPUG: perl2exe perl-cgi file size problem


>The script is now only using param from CGI, and all the
>rest is Perl...

If you're just reading text form input (IE not uploading from a
multipart/form-data enctype form) and your form(s) don't include
multi-select menues or multiple check boxes with the same name parameter,
use this and and replace $q -> param('formfieldname') with $q ->
{'formfieldname'}

unless($q = &GetFormData) {
    # handle errors
}

#########
# PURPOSE   Reads input from a HTML form
# RETURNS   A pointer to the data hash or 0 (the integer zero) if there's a
problem
sub GetFormData {
    local $in;  %in = ();
    local($name, $value) ;
    if ($ENV{'REQUEST_METHOD'} eq 'GET') {
        $in= $ENV{'QUERY_STRING'};
    } else {
        length($ENV{'CONTENT_LENGTH'})  || return 0;  # Read entire string
of CGI vars into $in
        read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) ;
    }
    length($in) || return 0;  # no form data received
    foreach (split('&', $in)) {  # Resolve and unencode name/value pairs
into %in
        s/\+/ /g ;
        ($name, $value)= split('=', $_, 2) ;
        $name=~ s/%(..)/chr(hex($1))/ge ;
        $value=~ s/%(..)/chr(hex($1))/ge ;
        $in{$name}.= $value ;  # modify this if you want to support
multiples
    }
    foreach $key (keys %in) {  # strip empty form fields
        delete $in{$key} if ($in{$key} eq "");
    }
    return \%in;
}

>> Ken Clarke
>> Contract Web Programmer / E-commerce Technologist
>> www.perlprogrammer.net :: www.modperldev.com



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list