Greetings, Monks!

Currently, I realize that I have way to many links cluttering my computer. When I find an interesting link, I mail it to myself, which now has my email folder filled with 2000+ links. In order to combat that, I wrote a script (discussed in Perl MIME parser partially works) to pull those links from my email and add them to a logfile.

The problem is that I also have shortcuts from my Firefox bookmarks, Internet Explorer shortcuts from right clicking and bookmarking pages, etc.

What I am trying to do, and need help with, is organizing these links into a logfile. From the email parser I am currently using, I have modified the logging to log 3 things : The link, the title of the page (taken from $Subject), and the date that it was sent (taken from $date).

I basically want to do the following:

- log the urls to a text file (for this example, URLs.txt), in a format similar to Url|Title|Date(s)|Count (If seen multiple times, it would be Url|Title|10/31/05 5:54PM, 01/05/10 10:10AM| Count: 2)

- be able to parse more urls (Bookmarks exported from Firefox, or shortcuts, or future emails), and increment any values seen in the previous logfile (URLS.txt), so that if the link was previously seen it would increment it and add any relative information.

My first thought is to use a hash, like

$seen{$item}{count}++ # to increment the Count push @urls, $item unless $seen{$item} $seen{$item}++ # To store the url
But how would I do this with all of the values I want to save? The above looks like it would store the url, and nothing else in its current form. I figure a push would take care of the dates, but I'm not sure how to implement it. How would I do something so I ended up with something like...
@urls = ( { url => 'http://www.url.com', title => 'The secret to Perl', date => '@dates that were pushed', count => '5' }, { url => 'http://www.google.com/page?id=blah', title => 'Google Search results for blah', date => '01/05/10 7:44PM, 05/10/12 8:12AM', count => '2' );
Apologies for the long rambling post, and I hope I explained everthing well enough. I couldn't exactly figure out how to describe what I needed, so hopefully this got it down!

In reply to 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.