in reply to Re^4: $cgi->param() values are not updated instantly when read in a subroutine
in thread $cgi->param() values are not updated instantly when read in a subroutine

The server is pretty much a standard installation...

due to cgi-bin, I'll assume you're running under mod_cgi

Although, seeing how your program seems to misbehave, that probably isn't the case.

And there are no warnings in the server logs??

Try this

#!/usr/bin/perl -w -- use strict; use warnings; use utf8; #this perl-file is written in utf-8 use CGI; use Data::Dumper; #zum debuggen Main(@ARGV); exit(0); sub Main { binmode STDOUT, ":encoding(utf8)"; my $cgi = CGI->new; $cgi->charset('UTF-8'); # Content-Type: text/html; charset=UTF-8 ## AND <meta http-equiv="Content-Type" content="text/html; charset=ut +f-8" /> print $cgi->header(); # Write HTTP header print $cgi->start_html, $cgi->b(rand time, ' ', scalar gmtime), $cgi->start_form, $cgi->textfield('creators_name'), $cgi->submit, $cgi->end_form, '<table border="1" width="%100"><tr><td>', $cgi->Dump, '</td><td><div style="white-space: pre-wrap; overflow: scroll;">', $cgi->escapeHTML( Dumper( $cgi ) ), '</div></td></tr></table>', CGI->new( \%ENV )->Dump, $cgi->end_html; }
  • Comment on Re^5: $cgi->param() values are not updated instantly when read in a subroutine
  • Download Code

Replies are listed 'Best First'.
Re^6: $cgi->param() values are not updated instantly when read in a subroutine
by Lukas (Initiate) on Mar 09, 2011 at 16:59 UTC
    I'm currently on the way, so I don't have all data available. However, I had a peek at the logs and I read something about $cgi (and maybe others) that it will not stay shared or so. I think its the thing described here: http://www.webreference.com/programming/perl/subroutines/2.html (at the end of "Private Variables and Nested Subroutines"). I'll have a look at it tomorrow. Thank you for your help so far.

      I had a peek at the logs and I read something about $cgi (and maybe others) that it will not stay shared or so

      You can't use my outside of subs in an Apache::Registry script. Refer to the mod_perl Guide. Possible solutions:

      sub foo { my ($cgi, ...) = @_; ... $cgi->... ... } sub main { my $cgi = ...; foo($cgi, ...); } main();
      or
      our $foo; sub foo { my (...) = @_; ... $cgi->... ... } sub main { local $cgi = ...; foo(...); } main();