You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ro...@ds-fr.com on 2001/01/10 12:00:58 UTC

Apache::Registry newbie question -- CGI state

I am trying to implement Example 2-14 in Stein and MacEachern.
Here's my code:

#!/usr/bin/perl
# file: hello.cgi
use CGI qw(:standard);
use strict;
my $name = param('name') || 'Anonymous';
print header(),start_html(-title=>'Yo!', -bgcolor=>'yellow'),
  h1("Hello $name"),
  p(  "To change your name, enter it into the text field below and press",
em("change name.") ),

  start_form(),
    "Name: ",
    textfield(-name=>'name', -value=>'Anonymous'),
    submit(-value=>'Change Name'),
  end_form(),

  hr(),
  end_html();

It works once -- BUT -- the value entered after the first appearance with
'Anonymous',
sticks and never changes
despite submitting the form again and again.

I thought that each invocation via CGI would change the value of param('name')?
I understand the code has been compiled once and is now running thru
Apache::Registry.
Nevertheless, shouldn't new param() values be visable?