How to generate radio buttons in Perl/CGI script with call to shell
am 24.11.2007 05:24:23 von prelim_questionsMy background: I am very new to Perl, CGI, and HTML. UNIX is okay.
I want to generate many (say 50+) radio_groups, each occurring on a
different webpage (like a quiz). The most convenient way for me to do
this is for each radio group to reference a particular file in my
directory which contains the appropriate question and possible answers
(different file for each radio group).
So for example:
Instead of hand typing each radio group like this:
print "
How far can they fly?
",
radio_group(
-name=>'how far',
-values=>['10 ft','1 mile','10 miles','real
far'],
-default=>'1 mile'); # (example from
perldoc)
I want to automatically generate this form with something like:
print "
$question
",
radio_group(
-name=>$id,
-values=>[$value1,$value2,$value3,$value4],
-default=>$value1);
where $question=` cat /home/username/file1 | head -1` { or however
you say the first line of a file in Perl}
and [$value1,$value2,$value3,$value4] = {the remaining 4 lines in /
home/username/file1}.
Now to make it slightly more complicated, each file is generated by a
shell script which I would prefer to reference directly in my Perl
script. In case that is not clear, say I use ./home/username/
radio_script -option1 to generate file1
../home/username/radio_script -option2 to generate file2
etc.
I have tried many variations on the system command to do this without
success. How do I do this?
Undoubtedly, I have may have been unclear at times. Please ask, and I
can clarify.
Thanks!