#!/usr/local/bin/perl print render(1); sub render { my $id = shift; $HTML = return_html($id); $HTML =~ s//render($1)/eg; return $HTML; } ### this sub is only here to mimic database lookups sub return_html { my $id = shift; if ( $id == 1 ) { return ' hello world

Hello world

'; } if ( $id == 2 ) { return ''; } if ( $id == 3 ) { return ''; } if ( $id == 4 ) { return '2014 '; } if ( $id == 5 ) { return 'and 2015'; } }