Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: CGI command newbie question

by benn (Vicar)
on Aug 07, 2003 at 14:22 UTC ( #281900=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://281900]
[ksbehal]: I need to test a .pl file for unit testing and integration testing. I tried to use the Test::More but when I am doing require_ok, it is executing the given script which i do not want.. any way out??

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-01-24 12:38 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (204 votes). Check out past polls.