in reply to Re^2: CGI: Passing variables to a subroutine
in thread CGI: Passing variables to a subroutine

Use a dispatch handler.

my %handlers = ( first => \&display_first, second => \&display_second, ... ); my $handler = $handlers{$query->param( "button" )}; if (!$handler) { ... } $handler->($query, $region, $var1, $var2, $var3);

You might even want to make some of those variables global, especially if they aren't changed after being set. Alternatively, the handler could use $query to get the variables it needs.