### begin_: init perl use strict; use warnings; my $app; ### begin_: call our 'Clone Generator' CloneSubroutines(); ### begin_: print some results print $app->{show_tag_a}('alpha') . qq'\n'; print $app->{show_tag_b}('bravo') . qq'\n'; print $app->{show_tag_c}('charlie') . qq'\n'; print $app->{show_tag_g}('delta') . qq'\n'; ### --- print &main::show_tag_e('echo'); print show_tag_f('foxtrot'); ### begin_: declare our 'Clone Generator' subroutine sub CloneSubroutines { ### simple example; create different types ### of 'tags' using perl data variables $app->{tag_a} = ['', '']; $app->{tag_b} = ['', '']; $app->{tag_c} = ['', '']; $app->{tag_d} = ['', '']; $app->{tag_e} = ['', '']; $app->{tag_f} = ['', '']; $app->{tag_g} = ['', '']; ### auto-generate (Clone) numerous subroutines ### based on a single subroutine template ### BUGNAG: must use no strict 'refs' pragma for my $tag (sort keys %{$app}) { no strict 'refs'; my $functionName = qq'show_$tag'; ### clone subroutines $app->{$functionName} = sub { my $beg = $app->{$tag}[0]; my $end = $app->{$tag}[1]; my $mid = shift || ''; my $strOut = ''; $strOut = qq'$beg$mid$end'; return $strOut; }; ### copy subroutines *$functionName = $app->{$functionName}; } }###end_sub 1; __END__ alpha bravo charlie delta echofoxtrot