in reply to variables not posting?

Always, always, always
#!/usr/bin/perl -w use strict;
Then USEFUL error messages are output
I think the following modified code may help
#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); read (STDIN,my($temp), $ENV{'CONTENT_LENGTH'}); my (@pairs) =split(/&/,$temp); my($item) = ""; my %fields; foreach $item(@pairs) { my($key,$content) =split (/=/, $item, 2); $content=~tr/+/ /; $content=~s/%(..)/pack("c",hex($1))/ge; $fields{$key}=$content; } print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<HEAD>\n"; print "<TITLE>This is a test of the stuffy perl network</TITLE>\n"; print "</HEAD>\n"; print "<BODY>\n"; print "$fields{tool}\n"; print "$fields{month}\n"; print "$fields{date}, $fields{month}\n"; print "</BODY>\n</HTML>";
Note the declaration of my %fields before the loop
Hope this helps

Replies are listed 'Best First'.
Re: Re: variables not posting?
by stuffy (Monk) on May 03, 2001 at 11:19 UTC
    That did help, thanks. I was wondering if somemonk could explaine why that worked, and why I needed to do that. Stuffy
      When you declare %fields inside the scope of the foreach $item (@pairs) loop with my, its contents are private to that loop. Then you try to access %fields after the loop, but it doesn't contain anything since you're outside the closing bracket (scope) of the for loop.

      -w and use strict tell of such errors.

      With your my declaration in the foreach loop you declared the hash locally.
      So the values you put into it weren't known outside.

      With using strict something like this can't happen because perl will give you an error.

      Have a look here for something more on my.
      You can also do a Super Search