Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Go to?

by Ronnie (Scribe)
on Apr 06, 2006 at 14:01 UTC ( #541639=note: print w/replies, xml ) Need Help??


in reply to Re^3: Go to?
in thread Go to?

Thanks for this - it has definite possibilities! Sorry if the experience comment offended but I didn't mean programming experience (knowledge) I meant in the sense of different employers and the constraints that might apply depending on employer! I can't change the original code I can only apply a wrapper! One (well more than one but point me at the right place and I should work the rest out for myself), question that occurs is - line 34 is setting an execute flag against each value held on the hash table? Which book covers this - I've bought most of the O'Reilly books - and this is definately outwith my current Perl knowledge!
Cheers,
Ronnie

Replies are listed 'Best First'.
Re^5: Go to?
by McDarren (Abbot) on Apr 06, 2006 at 16:10 UTC
    question that occurs is - line 34 is setting an execute flag against each value held on the hash table?
    Well, sortof...
    The "execute" is just really a label. The line that you refer to...
    # Set everything to initially be executed for (keys %scripts) { $scripts{$_}{execute}++; }
    ..just iterates through the hash, incrementing the value of $scripts{$key}{execute} for each $key. As none of these keys exist at this point, they are created (autovivication) and their respective values are set to 1.

    So what we end up with is..

    $scripts{1}{execute} = 1 $scripts{2}{execute} = 1 etc...
    The same thing happens a little later on (on line 45)...
    for (keys %scripts) { $scripts{$_}{execute}=undef; }
    ...but here we're setting them all to undef.

    Then when we get into the main loop, the first thing we do is to test whether that key exists, and if it doesn't we skip it and move on to the next one...

    # Skip this one if we need to next SCRIPT if !defined $scripts{$script}{execute};
    Incidentally, those for loops above could be done a little more elegently (and more efficiently) with a map...
    map { $scripts{$_}{execute}++; } keys %scripts;

    Which book covers this - I've bought most of the O'Reilly books
    Perl books that I have and would recommend are: I have several others, but they are the three that I personally refer to most often.
    in the sense of different employers and the constraints that might apply depending on employer!
    Actually, I can empathise with this. I have recently changed employer and moved from an environment that was primarily *nix to one that is primarly *shudder* 'doze. And it hurts, believe me. But fortunately, I am in a position where I do have some level of control - so I'm busily replacing windows boxes with Linux ones whenever and where-ever I can ;)

    Finally...

    Sorry if the experience comment offended
    None taken. And I _was_ going to let it (and the other comments) go. But after I thought about it a bit I decided that I needed to clarify my position as I felt that I'd been misunderstood (and mis-represented).

    Cheers, and good luck with your task at hand!
    Darren :)

      In light of your excellent help I think i can safely say that I won't require a goto - other than goto the Perl books and read up on hash tables and autovivication which I can barely spell never mind comprehend! I thought you were generating an execute label/attribute in flight so to speak but wasn't aware you could do that (or what that was called)!

      Many thanks,
      Ronnie

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-09-25 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (195 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!