package self; sub setup { my ($self) = shift; # Set the CGI parameter from which the run-mode of the application is derived to be 'stage' - This method allows you to set your own run-mode specifier, passed to your CGI script via hidden HTML form input tags # $self->mode_param('stage'); # Set the matched run-mode / subroutine functions to determine which function should be executed for a given run-mode - This method is that which allows reusable code to be easily implemented for separate run-mode. # # In this example, the subroutines 'display_form' and 'display_results' have been specified to run for run-modes '1' and '2' respectively. The subroutines can be defined as either a hard reference to the run-mode method or the name of the run-mode method to be called. # $self->run_modes({ '1' => \&display_form, '2' => 'display_results', }); # Set the mode which should be run in the first instance of the script, where no run-mode may be specified by a passed CGI variable - By default, this mode is called 'start', which too must be referenced to a subroutine via the run_modes() method. # $self->start_mode('1'); }; 1;