G'day PerlMonger79,

As others have already indicated, there are various aspects of your post that make it difficult to know exactly what you want; I won't repeat those here. The following is, I believe, the guts of what you're after.

I've used the second set of example data that you posted (in "Re^2: Parse file and creating hashes"):

$ cat pm_11140267_input.txt 702005010683593,5016683593,7020000024140 702005010640383,5016640383,7020000024150 310005010532143,5016532143,7020000034001 702005010637702,5016637702,7020000034001 702005010608274,5016608274,7020000034013 702005010608274,5016608274,7020000034013 310005010609604,5016609604,7020000034013 702005010510869,5016510869,7020000034013 702005010551513,5016551513,7020000034130 702005010551513,5016551513,7020000034130 702005010679719,5016679719,7020000034222 702005010527052,5016527052,7020000034222 702005010645458,5016645458,7020000034222

Here's a working demo script:

#!/usr/bin/env perl use strict; use warnings; use autodie; my $infile = 'pm_11140267_input.txt'; my $min_to_keep = 2; # 30 for production my %data; { open my $fh, '<', $infile; while (<$fh>) { chomp; my (undef, $col2, $col3) = unpack 'A15xA10xA13'; push @{$data{$col3}}, $col2; } } # For demo only: print "Interim results:\n"; use Data::Dump; dd \%data; print "\nWanted output data:\n"; for (sort keys %data) { next if @{$data{$_}} < $min_to_keep; print "$_: ", join(', ', @{$data{$_}}), "\n"; }

This outputs:

Interim results: { "7020000024140" => [5016683593], "7020000024150" => [5016640383], "7020000034001" => [5016532143, 5016637702], "7020000034013" => [5016608274, 5016608274, 5016609604, 5016510869], "7020000034130" => [5016551513, 5016551513], "7020000034222" => [5016679719, 5016527052, 5016645458], } Wanted output data: 7020000034001: 5016532143, 5016637702 7020000034013: 5016608274, 5016608274, 5016609604, 5016510869 7020000034130: 5016551513, 5016551513 7020000034222: 5016679719, 5016527052, 5016645458

— Ken


In reply to Re: Parse file and creating hashes by kcott
in thread Parse file and creating hashes by PerlMonger79

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.