That looks like a candidate for some light weight OO and named parameters. Consider:
use strict; use warnings; my $obj = bless {flibble => 1, floop => 2, flop => 3}; $obj->work(nuts => 7, bolts => 5); sub work{ my ($self, %params) = @_; $self->more_work(%params); print "$params{nuts}\n" if $self->{flibble}; } sub more_work{ my ($self, %params) = @_; $self->even_more_work(%params); print "$params{bolts}\n" if $self->{floop} > 1; } sub even_more_work{ my ($self, %params) = @_; my $sum = $params{nuts} + $params{bolts}; print "$sum\n" if $self->{flop} == 3; }
Although in real code a constructor would check important parameters and subs would check that any required named parameters are as expected.
In reply to Re^3: Avoiding Globals with OO Perl
by GrandFather
in thread Avoiding Globals with OO Perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |