Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Too much recursion

by Dallaylaen (Friar)
on Jun 27, 2013 at 15:53 UTC ( #1041041=note: print w/replies, xml ) Need Help??


in reply to Too much recursion

It looks like you are reading some kind of configuration file. I would suggest using a primitive state machine, something like:

my $host; while (<$fh>) { if (/^hostname/) { $host = new_host( $_ ); next; }; if ($host) { add_to_host( $host, $_ ); }; }; sub new_host { ... }; # return id of new host section sub add_to_host { ... }; # do whatever is needed

I don't know what the file format is, and what the code really should do, so I can't say what's in the two last subs. At least there's no recursion, and you can process as many hostnames as you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041041]
help
Chatterbox?
[marioroy]: CORE::wait can block if another process reaps a worker from another class. MCE::Hobo takes care of that and transparently.
[Discipulus]: thanks choroba i'll update my answer
[Lady_Aleena]: Hello Discipulus, Corion, choroba, and marioroy...
[Corion]: Hi Lady_Aleena!
[Lady_Aleena]: marioroy, are you also writing a Meditation for this?
choroba o/
Discipulus adds tozzetti alle mandorle to the platter on the sideboard.
Lady_Aleena was checking #cbstream and saw the big announcement.
[marioroy]: Tie::IxHash can be shared. Also similar modules. I cannot wait to post a solution sharing Tie::File and iterating among workers.
[marioroy]: Lady_Aleena Yes, will post something with all the new features. Parallel with few lines of code.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2017-05-26 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?