#!/usr/local/bin/perl use warnings; use 5.012; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use JSON; my $ref = [ [ 1, 'eins', '12/11/10', 'sn' ], [ 2, 'zwei', '11/12/09', 'cp' ], [ 3, 'drei', '04/09/11', 'cp' ], ]; my @radio_values; for my $el ( @$ref ) { push @radio_values, encode_json $el; } my $cgi = new CGI(); my $step = $cgi->param('step') // 0; my @functions = ( \&eins, \&zwei, \&drei ); my $function = $functions[$step] or die "invalid $step"; my $hidden = $cgi->hidden( -name => 'step', -value => $step+1 ); $function->(); sub eins { print $cgi->header(); print $cgi->start_html(); print $cgi->startform(); print $cgi->radio_group( -name => 'choice', -values => [ @radio_values ], -linebreak => 'true' ); print $hidden; print $cgi->submit( 'OK' ); print $cgi->endform(); print $cgi->end_html(); } sub zwei { my $choice = $cgi->param('choice'); print $cgi->header(); print $cgi->start_html(); print $cgi->startform(); print $cgi->h2( "Rating: $choice" ); print $cgi->popup_menu( -name => 'rating', -values => [ '+++', '++', '+', '0', '-', '--', '---' ], -default => '0' ); print $cgi->br(); print $cgi->hidden( -name => 'choice', -value => $choice ); print $hidden; print $cgi->submit( 'OK' ); print $cgi->endform(); print $cgi->end_html(); } sub drei { my $choice = $cgi->param('choice'); my $rating = $cgi->param('rating'); my $a_ref = decode_json $choice; my $name = $a_ref->[1]; my $table = $a_ref->[-1]; print $cgi->header(); print $cgi->start_html(); print $cgi->p( "Table: $table
Name: $name
RATING: $rating" ); print $cgi->end_html(); }