perlquestion
bradcathey
<p>Fellow Monks,</p>
<p>My program calls a large (200 lines) internal subroutine about 1/3 of the time the script is run. The subroutine requires 4 arguments to run and returns a AoH ref for output to HTML::Template. To complicate matters, it calls other sub routines (5 and 10 liners that are only needed by that large sub) to perform basic formatting tasks, etc. So, things currently look like:</p>
<blockquote><code>
#!/usr/bin/perl
use strict;
...etc...
...initiate variables...
...HTML::Template setup...
my $AoH = &largesub($a, $b, $c, $d) if $run_large_sub;
$template -> param( todisplay => $AoH );
print $template->output();
exit();
sub largesub {
my ($e, $f, $g, $h) = @_;
my $foo = &smallsub($e);
...process...
return \@AoH;
}
sub smallsub {
...process...
}
</code></blockquote>
<p><b>Questions:</b> <b>1)</b> do I leave it as is? (seems messy) <b>2)</b> do I spin off the large sub and it supporting subs as a module? (modules always get loaded) <b>3)</b> do I use Selfloader to avoid loading all those subs? (subs stay in main script, but don't always get loaded) <b>4)</b> What is the cleanest, most efficient, most readable solution? Thanks!</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-273627">
<br>—Brad<br><small><i>"Don't ever take a fence down until you know the reason it was put up. "</i> G. K. Chesterton</small><br>
</div></div>