in reply to Unique & sorted array optimization?
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:
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.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;
I will let you fix that for yourself.
|
|---|