We all learn at different speeds and many times the speed we learn at is proportional to the time we spend. If your life is busy and you only get a little bit of time to spend on this, the natural result is that it'll take longer to learn. That's natural and there's nothing wrong with that. I do applaud your willingness to hang in there and continue; I'm sure that determination will get you where you want eventually.
As to your problem, looking at and understanding classic problems is a decent way to learn. Many of us wouldn't solve it that way, but that's because we're probably trying to solve a business problem and not teach ourselves something. We'll grab the first thing that works and use it.
As I'm lazy, I'd probably just use the hash and do:
@arr = ( ...as defined in the problem... );
%h = map { $_ => undef } @arr;
print join(" , ",keys(%h)), "\n"';
There's probably even a way to do that in 1 line, but again, I'm lazy. :)
Besides all the other good advice you've been given, I'll add 1 more I didn't see (my apologies to anyone if I overlooked this in your post).
I believe someone did say they keep snippets of code, which we all do, but I'll advise you to go further. I actually keep a notebook of code examples and explanations from PerlMonks/blogs/web-searches/books/etc for reference, not to mention little things I've found on my own over time that are helpful. I put it in an electronic notebook for easy searching and organization (I use OneNote, but use whatever works for you). It's grown over the years and has become a helpful companion along the way -- a trusty toolbox of tips and tricks and reminders.
Good luck in your journey, and sign up and join us here too. :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.