Intrepid has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Unique & sorted array optimization?
by tilly (Archbishop) on Aug 05, 2000 at 04:41 UTC
    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.

(Ovid) Re: Unique & sorted array optimization?
by Ovid (Cardinal) on Aug 05, 2000 at 04:14 UTC
    Can any of our esteemed Wise Ones see a bloat that ought to be corrected here?

    Hmm... how about an excess of font tags? Your post has blue fonts which are invisible in the blue theme that I am using.

    Cheers,
    Ovid

    A reply falls below the community's threshold of quality. You may see it by logging in.