G'day NetWallah,
"I'm looking for comments on how to avoid/minimize the global declarations."
I haven't tested your code, nor delved into your logic;
however, in response to that specific request for comments, this type of structure may do what you want:
{
my $actionFlag = 'NONE';
my $Options = build_options(\$actionFlag);
my $stack = [[ 'Options', $Options ]];
while ($actionFlag ne 'EXIT') {
...
pop @$stack if @$stack > 1;
...
Display_Options_and_Get_Response($stack);
}
}
sub Display_Options_and_Get_Response {
my $stack = shift;
my ($header, $opt) = @{$stack->[-1]}[0, 1];
...
push @$stack, [ ... ];
...
}
sub build_options {
my $action_flag_ref = shift;
return [
...
sub { ... $$action_flag_ref = 'EXIT' }
...
];
}