Consider a hash of arrays of arrays (HoAoA), where the keys are the urls and the associated value is a reference to an array of arrays:

use strict; use warnings; use Data::Dumper; my %hash; while (<DATA>) { chomp; my ( $url, $subject, $date ) = split /\t/; $hash{$url}->[0] //= $subject; push @{ $hash{$url}[1] }, $date; } local $" = ', '; print "Url|Title|Date(s)|Count\n"; for my $key ( keys %hash ) { print "$key|$hash{$key}->[0]|@{ $hash{$key}[1] }|" . scalar @{ $hash{$key}[1] } . "\n"; } print "\n", Dumper \%hash; __DATA__ http://www.perl.com Perl 01/05/10 7:44PM http://www.google.com/page?id=blah Google Search results for blah + 01/05/10 7:44PM http://www.google.com/page?id=blah Google Search results for blah + 05/10/12 8:12AM http://www.perl.com Perl 01/05/10 7:42AM http://www.perl.com Perl 01/10/10 9:44PMM

Output:

Url|Title|Date(s)|Count http://www.google.com/page?id=blah|Google Search results for blah|01/0 +5/10 7:44PM, 05/10/12 8:12AM|2 http://www.perl.com|Perl|01/05/10 7:44PM, 01/05/10 7:42AM, 01/10/10 9: +44PM|3 $VAR1 = { 'http://www.google.com/page?id=blah' => [ 'Google Search res +ults for blah', [ '01/05/10 7:44PM +', '05/10/12 8:12AM +' ] ], 'http://www.perl.com' => [ 'Perl', [ '01/05/10 7:44PM', '01/05/10 7:42AM', '01/10/10 9:44PM' ] ] };

In reply to Re: Organizing Links - Better to use hash, hash of arrays, or...? by Kenosis
in thread Organizing Links - Better to use hash, hash of arrays, or...? by CalebH

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.