http://www.perlmonks.org?node_id=281900


in reply to CGI command newbie question

Errmmm...I *think* you're looking for a generic mechanism to add various buttons and then act on them - maybe something like this (untested)...?
my @commands = qw(ping traceroute whois other stuff); print $q->start_form(-method=>'POST',-action=>'formDB.cgi'); print $q->hidden(-name=>'val',-value=>"$ciccio[2]"); print $q->submit(uc($_)) foreach (@commands); print $q->end_form;
...then you could maybe use a dispatch table...something like...
my $dispatch = { ping => sub { return my_ping($_[0])}, traceroute => sub { return my_traceroute($_[0])}, etc. => }; foreach (@commands) { $dispatch->{$_}->($q->param('val')) if (defined $q->param(uc($_))); }
Hope this helps, Ben.