It seems like you might be making your learning process more difficult or time consuming than it needs to be. Don't worry about guessing what the author's intent may have been regarding the particular code that should solve a given exercise.

The author knows there are many ways to solve each exercise with Perl, and your real task here is simply to figure out at least one way to do it and move on to the next exercise or the next chapter. If hashes have been mentioned at all prior to this particular exercise, then use a hash. Even if the book hasn't mentioned hashes yet, but you know about them from studying other sources, use a hash and move on. You should not assume that the author wants you to come up with some other sub-optimal solution that will be of no use to you in the future.

As you get further along in that book, if you find this sort of exercise being repeated with a focus on using hashes, you'll just get through that part more quickly because you've already learned it.

I know of a teaching method that works like this: (1) introduce some basic tools; (2) build familiarity and facility with these using simple exercises; (3) introduce more complex exercises, forcing students to do lots of tedious, mind-numbing, time-consuming work; (4) introduce some advanced tools and show how the more complex problems can be solved quickly and easily.

This was the method used when I was first introduced to calculus in high school, and it was pretty effective, but it takes a lot longer than just saying "when you have this sort of problem, here is the quickest, easiest way to solve it." These days (nearly 40 years later), I tend to favor the latter approach -- life is short, and you should take the long way around only if you really enjoy doing that and it holds some greater value for you personally (and you actually have the extra time to spare).


In reply to Re: Saving array duplicates, not using a hash? by graff
in thread Saving array duplicates, not using a hash? by gctaylor1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.