Hi,
I have been reading up on lexical and package variables but this branch is just out of my reach.
I am submitting a basic form to a cgi - the problem is the perl cgi is outdated and i dont know how to translate the code into lexical. The refernced $key values keep throwing a undefined global at $Form data so i threw a few 'my's at it. now the erorrs are syntax at "$FORM_DATA{" around lines 60. Where might I go from here?
#! /usr/bin/perl -Tw use strict; use warnings; use CGI::Carp qw(fatalsToBrowser), qw(warningsToBrowser); my ($webmaster, $user); our($FORM_DATA, $change_text); $webmaster = "http\:\/\/www.mysite.com\/"; &parseform(*change_text); print "Content-type: text/plain\r\n\r\n"; # $user = $change_text{'user'}; print "\$user:\n$user\n\n"; exit(0); sub parseform { local (*FORM_DATA) = @_; my ( $reqmet, $qst, $keyval, $key, $val, $keyvalpears); $reqmet = $ENV{'REQUEST_METHOD'}; if ($reqmet eq "GET") { print "This type of request is not accepted please update via +the authenticated edit form at $webmaster"; } elsif($reqmet eq "POST"){ read (STDIN, $qst, $ENV{'CONTENT_LENGTH'}); } else { &reterr (500, "Server Error", "Server uses unsupported method"); } print "\$qst:\n$qst\n\n"; @keyvalpears = split (/&/, $qst); print "\@keyvalpears:\n@keyvalpears\n\n"; foreach $keyval (@keyvalpears) { ($key, $val) = split (/=/, $keyval); $val =~ tr/+/ /; $val =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; # if defined no need to use anymore re my? if(defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $val); }else{ $FORM_DATA{$key} = $val; } print "\$FORM_DATA val :\n$FORM_DATA{$val}\n\n"; } } sub reterr { my ($status, $keyword, $message) = @_; print "Content-type: text/html", "\r\n\r\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print <<End_of_Error; <HTML> <HEAD> <TITLE>CGI Program - Unexpected Error</TITLE> </HEAD> <BODY> <H1>$keyword</H1> <HR>$message<HR> Please contact $webmaster for more information. </BODY> </HTML> End_of_Error exit(1); }
In reply to globbed variable in parse cgi form - beyond me by Don Coyote
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |