in reply to Taking Variable from Form Entry Using CGI

Are you not using CGI because you want to know how's the guts of all that stuff?

Then you should dump all your environment variables and what you read from STDIN into some file and examine it.

As for POST, I doubt that this works:

# Split the name-value pairs @pairs = split(/&/, $query_string);

Otherwise, just use CGI and have that module give you the content of the textarea:

#!/usr/local/bin/perl use CGI; use strict; my $q = CGI->new; print $q->header; my $text = $q->param('comments'); my $words = scalar(split (/ /, $text)); #Give output print <<END; <html><head> <title>Guest book Result</title> <body> <h1 align="center">Guest book Results</h1> <br> Comments : $text <br> Words: $words </body> </html> END
Cleaner code, less hassle.

cheers,
--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Taking Variable from Form Entry Using CGI
by sdslrn123 (Novice) on Jul 02, 2006 at 15:17 UTC
    Thanks for the reply. Unfortunately, I get the following error:
    Can't locate HTML/TokeParser/Simple.pm in @INC (@INC contains: C:/Prog +ram Files/xampp/perl/site/lib/ C:/Program Files/xampp/perl/lib C:/Pro +gram Files/xampp/perl/site/lib . C:/Program Files/xampp/apache) at (e +val 76) line 19. BEGIN failed--compilation aborted at (eval 76) line +19. ,
    But, when I go to ppm in activestate it says I have installed this module. Any suggestions?
      The CGI.pm included with the perl core doesn't use HTML::TokeParser::Simple (at my unix box, that is - dunno of windows). It must be pulled in somewhere else. Use the search facility of the windows explorer to identify that file. If you just happen to use CGI, check the location of CGI like so
      print STDERR $INC{'CGI'}."\n";
      anywhere in your cgi file, and check the apache error_log. Many modules have a Package::whatever::CGI, but you should be using the core CGI.pm, not Package/whatever/CGI.pm.

      HTH,
      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      At the command prompt type the following:

      perl -MCGI -e "print $CGI::VERSION;"

      ...and then tell us what output you get. Do you still get that HTML::TokeParser error? If not, then the error has nothing to do with your use of CGI. If you do, I'm perplexed. ;)


      Dave