in reply to (jeffa) Re: cgi problem
in thread cgi problem

thanks jeffa,
but do you know why I still am unable to capture the variables from my html page. For the POST method it does in fact get to the cgi script and perform my little "INFO" routine but the values for the variables are empty.

Thanks again

Replies are listed 'Best First'.
(jeffa) 3Re: cgi problem
by jeffa (Bishop) on Dec 23, 2002 at 01:48 UTC
    Sorry, but i really just don't see what it could be with the info i have in front of me.

    <update>
    but gjb has eyes of gold ... gjb++
    </update>

    Off hand however, your INFO subroutine is using global variables, which is generally Not a Good Thing ™. Try passing it values instead:
    sub INFO { my ($company,$last,$first,$serial,$meter) = @_; print "COMPANY: $company\n"; print "LAST: $last\n"; print "FIRST: $first\n"; print "SERIAL: $serial\n"; print "METER: $meter\n"; } # you can call it like so: &INFO($company,$last,$first,$serial,$meter);
    Since all the variables have the same names, it seems kind of silly to pass them explicitly, but this is good practice to get into in the long run. Personally, i'd find a way to utilize a hash (and subroutines that print are not very portable, so return a string instead):
    use strict; use warnings; my %hash = ( COMPANY => 'Acme', LAST => 'Scott', FIRST => 'Randolph', SERIAL => 'number', METER => 'maid', ); print &INFO(%hash); sub INFO { my %params = @_; my $output; $output .= "$_ = $params{$_}\n" for keys %params; return $output; }
    Tie::IxHash will keep your keys ordered, should you need that.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)