Why would you think that bloat needs to be corrected? The goal is not to pack the most functionality in the fewest lines of text. It is to produce a program that works and can be read.

Now that the flame-bait is out of the way, that for() loop should be a foreach loop so you can drop the $itr variable, warnings should complain that $r is not used, the my declaration for $lk should be moved inside of the loop to localize it as much as possible, and $_ does not need to be assigned to in the map. Lemme see, that gets you down to this:

my %UHash; foreach my $pic (@Linked_pics) { # Meant to pick the filename out my $lk = substr($pic, 1 + rindex($pic, '/')); $UHash{$lk} = $pic; } @Linked_pics = map {$UHash{$_}} sort keys %UHash;
Oops, I accidentally made it shorter. And clearer. In fact so clear that it is now obvious that if the format of the URL changes, your code will break.

I will let you fix that for yourself.


In reply to Re: Unique & sorted array optimization? by tilly
in thread Unique & sorted array optimization? by Intrepid

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.