Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: New to Perl and need help

by kcott (Archbishop)
on Nov 02, 2017 at 07:11 UTC ( [id://1202574]=note: print w/replies, xml ) Need Help??


in reply to Re: New to Perl and need help
in thread New to Perl and need help

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' } ... ]; }

— Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found