Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
P is for Practical
 
PerlMonks  

Re: Comparing two hashes-help

by sundialsvc4 (Monsignor)
on Aug 20, 2010 at 20:06 UTC ( #856352=note: print w/ replies, xml ) Need Help??


in reply to Comparing two hashes-help

First of all, you should know that in this forum, you can be sure to be treated respectfully.   No matter how “new to Perl” you might or might not be.   This is a gathering-place of professionals.

Second...   I often find it useful to describe logic like this in terms of a finite-state machine (FSM).   The idea here is actually a simple one, despite the obfuscatory-sounding name.   It works like this:

  • You say that the algorithm (“machine”) can be “in” one of several “states” based upon its recent history.   (By definition, it always begins its life in some “initial” state.)
  • The main program is just a loop.   Each time through the loop, the program:
    • Based on the current state, and whatever is presented to it at this time, it chooses the next state to be in.
    • Then, it carries out some action appropriate to that new state.
  • The program continues in this way until it reaches a “stop” state.

So, to continue my extemporaneous-design exercise a bit farther, the algorithm could start in state SKIPPING_FOR_IDENTICAL_VALUES and, when it finds one, switch to LOOKING_FOR_BLANK_IN_FILE_1.   It would continue until it finally reached a stop-state of END_OF_BOTH_FILES_REACHED. (I hope...) you get the idea from this barest of sketches, which by the way is not specific to Perl.


Comment on Re: Comparing two hashes-help

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-04-21 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls