Happy-the-monk, that was stunning! I love it when I can replace 15 lines of code with only 2. I plugged it in and worked like a charm.
To be honest, I'm not sure how it works. My educated guess is it iterates through @AoH and assigns a key/value pair of
page => 1 for every element. But why does it skip the 5th element (the dupe)? When I Dumper, I get:
$VAR1 = 'fall';
$VAR2 = 1;
$VAR3 = 'winter';
$VAR4 = 1;
$VAR5 = 'spring';
$VAR6 = 1;
$VAR7 = 'summer';
$VAR8 = 1;
So, 1) why/how does it skip the dupe? 2) what does assigning the 1 do? 3) what does that 2nd line do to delete the key/value pairs of
page => 1? Also, any good sources for learning how to disect a map/grep would be much appreciated. Thanks again.
Update: Found this helpful
resource in the meantime.
—Brad
"A little yeast leavens the whole dough."
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.