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');