Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Comparing two hashes-help

by sundialsvc4 (Abbot)
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://856352]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-11-25 06:19 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (355 votes). Check out past polls.