in reply to Re^2: Avoiding Globals with OO Perl
in thread Avoiding Globals with OO Perl
work($a,$b,$c,$d,$e,$f); sub work{ my ($a,$b,$c,$d,$e,$f) = @_; more_work($b,$c); print "$a\n"; } more_work{ my ($b,$c) = @_; even_more_work($c); print "$b\n"; }
$d, $e, $f are never used, and $b & $c are only used by more_work().
Then perhaps what you should be doing is:
more_work( $b, $c ); work( $a )
Or if work() requires the results of more_work(), then maybe:
work( $a, more_work( $b, $c ) );
I realise that your example was just that, but it demonstrates the problem with using made-up examples rather than real ones. It becomes all too easy to exaggerate the effect of the perceived problem -- that of passing lots of data around -- whilst obscuring what is often the real problem -- poorly structured code.
|
|---|