Instead of javascript, you could just put the buttons in separate
<form> tags so they have different actions. (Why no javascript?)
<form action="prog1.cgi">
...
<input type="submit" value="View">
</form>
<hr>
<form action="prog2.cgi">
...
<input type="submit" value="Edit">
</form>
If you want to do it strictly on the backend, a couple thoughts come to mind. First is that the script you submit to simply looks at the button value and then does a redirect to the appropriate .cgi url (constructing a query string of course so values are preserved). Take a look at
CGI, specificall the
param() and
redirect methods.
Second backend way (and probably better) is that you just have one cgi file, but it (depending on the button value) calls code from different files (different "include" files or modules). Take a look in the
Tutorials section for basics on modules and
Including files.
my $btn = $q->param('button');
if( $btn eq 'viewBtn' ){
...
}elsif( $btn eq 'editBtn' ){
...
}else{
...
}