in reply to Re: Identifying duplicates in array or hash based on a subset of data
in thread Identifying duplicates in array or hash based on a subset of data

Hi johngg! I liked your post. I see what you did with the sprintf. The OP may not understand, so I include a demo for him (you already know this) showing why leading zeroes are necessary to get the "right" numeric result with an alpha sort. I didn't see the need for this, but you bring up a valid point if this matters.
#!/usr/bin/perl use warnings; use strict; # Simple alpha sort produces wrong numeric order here my @test = (qw/1 12 10 100 /); @test = sort @test; print "@test\n"; #prints "1 10 100 12" # With leading zero'es, we get "right" numeric answer @test = (qw/001 012 010 100/); @test = sort @test; print "@test\n"; #prints "001 010 012 100"
I have a small quibble with this line: foreach ( <$inFH> ). With this syntax, I figure that Perl will construct a list of stuff from $inFH and process that list. That will use more memory than a while (<$inFH>){} construct which reads one line at a time from the file handle. No biggie for small files, but this matters for "big" files.