Guys Thanks to all the useful suggestions, especially to Charles for the code review, I will implement your suggestions throughout my code.
But back to the original question. I need to put a lot of re-occurring code into subroutines (as you do) however I am hampered to a problem with passing shift I think. This is a very simplified test code where I have tried passing shift as an argument and also as a call (see commented out bits) both give the same error: "Error executing run mode 'mode_0': can't call method "param" on an undefined value at test_code.pm line 57 here is the code: package Test_code; use base 'CGI::Application'; use DBI; use strict; use warnings; ########################################################################## # Subroutine Name: setup # Purpose: To set up the start mode and the various run modes... # It also sets up the database. # 18-Nov-03 J.Bews :- Initial coding. # 23-Nov-03 J.Bews :- Changed location for the Templates. Now in the same # location as the HTML files. # 02-Dec-03 J.Bews :- Converted to OCL_Database. # 22-Dec-03 J.Bews :- Deleted mode_5. Incorporated into mode_4. # 14-May-04 J.Bews :- Realised that I was still using the old database # in the c:\Program Files\Abyss\cgi-bin\OCL_Database subdirectory. Changed # over to the C:\xitami\cgi-bin\OCL_Database subdirectory. ########################################################################## sub setup { my $self = shift; # Set the start mode. $self->start_mode('mode_0'); # Set the run modes. $self->run_modes ( 'mode_0'=>'mainmenu', 'mode_1'=>'insertproject', ); # Connect to the database using DBI and ODBC. # Open connection to an Access 97 database called 'Sample_db.mdb'. my $file = "c:\\xitami\\cgi-bin\\ToolBox\\OCL\\OCL.mdb"; my $driver = "driver={Microsoft Access Driver (*.mdb)}; DBQ=$file"; $self->param('mydbh' => DBI->connect("dbi:ODBC:$driver")); my $dbh = $self->param('mydbh'); $dbh->{'LongReadLen'}= 5000; # expand the size of the Memo read for Access 97 # Path to use for Templates.... #$self->tmpl_path('./'); # ie the same directory as this script. $self->tmpl_path("c:\\xitami\\webpages\\TestBed\\"); } ########################################################################## sub mainmenu { my $self = shift; # my @loop = GetOfficers($self); my @loop = GetOfficers(); } ########################################################################## sub GetOfficers { #my $self = @_; my $self = shift; my $sql = 'SELECT Name as HTML_ProjectName FROM qryOfficer'; my $dbh = $self->param('mydbh'); my $sth = $dbh->prepare( $sql ); $sth->execute()|| die qq(Could not execute SQL: "$sql"); return $sth->fetchall_arrayref(); } 1; Can anyone see how I can get the code to see the stuff. (my $dbh = $self->param('mydbh'); is line 57) TIA Mick Hawkes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>