Lukas has asked for the wisdom of the Perl Monks concerning the following question:
To reproduce do the following: Run the script. Fill in the value 1 and submit. You will see that all values will be 1. If you submit it again within 15 seconds with the value 2, the result will be:#!/usr/bin/perl -w use strict; use warnings; use CGI; use utf8; #this perl-file is written in utf-8 binmode STDOUT, ":encoding(utf8)"; #encode all output directed to STDO +UT (e.g. print) to browser as utf-8 use Data::Dumper; #zum debuggen my $cgi = new CGI; $cgi->charset('UTF-8'); # Let CGI.pm write 'Content-Type: text/html; c +harset=UTF-8' in the HTTP header print $cgi->header(); # Write HTTP header print "\$cgi->param('creators_name') (main)= " . $cgi->param('creators +_name') . "<br>"; my $creators_name_content = $cgi->param('creators_name') . ""; print "\$creators_name_content (main)= $creators_name_content<br>"; print_formular($creators_name_content); sub print_formular { print <<"END"; <!DOCTYPE html> <html lang="de-CH"> <head> <title>title</title> </head> <body > END print "\$cgi->param('creators_name') (sub)= " . $cgi->param('c +reators_name') . "<br>"; print "\$creators_name_content (sub)= $creators_name_content<b +r>"; print "\$creators_name_content (arg)= $_[0]<br>"; print <<"END"; <form action="shortingest.pl" accept-charset="utf-8" method="post" enc +type="multipart/form-data"> <table id="mytable"> <tr> <td><input name="creators_name" type="text" size="60" +value=""></td> </tr> <tr> <td><input type="submit" value="Submit"></td> </tr> </table> </form> </body> </html> END }
If you wait at least 15 seconds, the output will be what you expect. Do you have any pointers whats going on here?$cgi->param('creators_name') (main)= 2 $creators_name_content (main)= 2 $cgi->param('creators_name') (sub)= 1 $creators_name_content (sub)= 1 $creators_name_content (arg)= 2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $cgi->param() values are not updated instantly when read in a subroutine
by Anonymous Monk on Mar 09, 2011 at 13:20 UTC | |
by Lukas (Initiate) on Mar 09, 2011 at 13:33 UTC | |
by Anonymous Monk on Mar 09, 2011 at 13:38 UTC | |
by Lukas (Initiate) on Mar 09, 2011 at 13:48 UTC | |
by Anonymous Monk on Mar 09, 2011 at 14:40 UTC | |
| |
|
Re: $cgi->param() values are not updated instantly when read in a subroutine
by raybies (Chaplain) on Mar 09, 2011 at 15:21 UTC | |
by Anonymous Monk on Mar 09, 2011 at 15:37 UTC |