Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl use CGI qw/:standard/; my $new_cgi = new CGI; my $i=0; $| = 1; # no more buffering my $full_url = $new_cgi->url(); print header, start_html('Pattern editor'), h1('Pattern Edit Center'), start_form; open PATS, "pats.txt" or die "cannot open pats.txt\n"; while (<PATS>) { if (/^\#.*/) { chomp; print hidden(-name=>"key$i", -value=>" +$_"); $i++; next; } s/#.*//; # strip trailing comme +nts next unless /\S/; # skip blank lines my ($key, $val) = split /\t+/; $val = $key unless $val; print "<TR><TD><input type=text name=key$i siz +e=13 value=$key> </TR>\n"; print " <TD><input type=text name=val$i size=2 +4 value='$val'> </TD></TR>\n"; $i++; } close PATS; # use old style for now - clean up later... print "<TR><TD><input type=text name=key$i size=13 > < +/TR>\n"; print " <TD><input type=text name=val$i size=24 > </T +D></TR>\n"; print submit, end_form, hr; if (param()) { open PATS,">pats.txt" or die "Cannot open pats.txt\n"; my $j = 0; while ($j <= $i) { print PATS param("key$j"), "\t", param("val$j") . "\n"; $j++; } close PATS; # Now that I've written the file, I should be able # to refresh and read the values back in. But How? print redirect($full_url); # for debugging purposes, print the form values to the bottom of page $j=0; while ($j <= $i) { print em(param("key$j")), " ", em(param("val$j")),br; $j++; } hr; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: CGI refresh w/a twist
by jeffa (Bishop) on Jul 25, 2003 at 01:46 UTC | |
by Anonymous Monk on Jul 25, 2003 at 22:41 UTC | |
|
Re: CGI refresh w/a twist
by rupesh (Hermit) on Jul 25, 2003 at 09:46 UTC |