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.

In reply to Re^2: Identifying duplicates in array or hash based on a subset of data by Marshall
in thread Identifying duplicates in array or hash based on a subset of data by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.