WTF?
my $limit = shift;
$limit = 100;
if (!$limit) {
$limit = 20;
}
OMG...
my @files_raw = <$directory/*>;
my @files = sort { lc($b) cmp lc($a) } @files_raw;
OMFG...
foreach my $file (@files) {
if ($i < $limit) {
$i += 1;
# [...]
}
}
JFC...
Re:middle part makes sense
cog on 2008-08-02T23:43:55
That does make sense, but here's a bit more context (I tried posting only code in the above post):
- There are thousands of files in that directory (which implies the sort shouldn't be done that way)
- While the OS does make case-insensitive distinction, all the filenames are numbers (which both means that the lc is not doing anything useful, and that the comparison should not be done with cmp)
There. Is it scary now?
:-) FWIW, I don't have to do anything to this code, I just have to create the replacement system, but I'm going through the code as I implement, just to make sure there isn't any hidden functionality I'm not aware of.
Try this one:
my %oc_lang_assoc = {}
;
#...
%oc_lang_assoc->{$oc_id_key} = $language;
Re:that's nothing
cog on 2008-08-04T09:39:29
My first thought when I read "that's nothing" was: "Indeed... There's thousands more lines just like this one..."