sub print_multiple { my $b = shift; for (1..$b->{'count'}) { print &format_string ($b), "\n"; } return; } sub format_string { my $b = shift; my %templates = ( 'bold' => '%s', 'italic' => '%s', ); return ( sprintf ( $templates{ $b->{'format'} }, $b->{'string'} ) ); } $block = { 'string' => "hello, world.", 'format' => "bold", 'count' => 5, }; &print_multiple ($block);