my %Templates = ( header=>q{ #### HEADER #### # yadda yadda yadda ################ }, config=>q{ #### CONFIG #### # Sets the frobnitz #DEFINE FROBNITZ=Blevin ################ }, . . . ); sub get_template { my $tpl_name = shift; die "Template '$tpl_name' doesn't exist!" unless exists $Templates{$tpl_name}; return $Templates{$tpl_name}; } # Now you can use it like: print get_template('header'); #### sub help { my $NAME = $_[0]; . . . $NAME mangling . . . print <## sub gettime { my ($sec,$min,$hr,$day,$mon,$yr,$dayOfWeek) = localtime(); # Adjust the values to the values humans expect: $yr+=1900; $mon++; return "$weekDays[$dayOfWeek] $mon/$day/$yr $hr:$min:$sec"; } #### sub print_tempDB_report_from_file { my ($DB_FName, $RPT_FName) = @_; my $tempDB = parse_db_file($DB_FName); my $report = generate_db_report($tempDB); open my $OFH, '>', $RPT_FName or die "meaningless death!"; print $OFH $report; } sub parse_db_file { my $DB_FName = shift; . . . code to parse DB File into data structure . . . return $tmpDB; } sub generate_db_report { my $tmpDB = shift; my $text; . . . code to turn data structure into a string . . . return $text; } #### # Startup process_command_line(); perform_various_sanity_checks(); my ($user,$passwd) = get_login_data($CONFIGFILE); set_static_configuration(); # Do the work #### switch (c) { case 'A': do_this(); break; case 'B': do_that(); break; case 'C': do_this() && do_that(); }