*sigh*

cog on 2008-08-01T15:02:07

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...


LOL

ambs on 2008-08-01T15:15:45

PEBKAC

middle part makes sense

merlyn on 2008-08-02T22:13:30

If the OS gives you the names sorted with case distinction, but you wanted a case-insensitive sort, it's the right thing to do.

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.

that's nothing

slanning on 2008-08-04T07:52:00

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..."