Radio Button Demo: Output After Form
#!/usr/bin/perl -w
use Cwd;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print header;
print start_html("User chooses from a mutually exclusive group!");
print start_form(),
"Get one of the following: ",
radio_group(-name => 'pick_one',
-value => ['time', 'listing of current directory',
'name of current directory'])
, p, reset(-name => 'Reset'), submit(-name => 'Submit'), end_form;
if (param('pick_one'))
{
($choice) = param('pick_one'); # Parens around $choice NECESSARY!!
if ($choice eq "time") {print scalar(localtime(time)), "\n"}
elsif ($choice eq "listing of current directory")
{
opendir(D, ".") or die "Cannot open current directory!\n";
@files = sort readdir D;
print ol(li(\@files));
closedir D;
}
else {print p(cwd())} # cwd() gives current working directory!
}
else {print p("No request yet made!")}
print end_html;