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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.