Wise monks,

I am trying to wrap my head around a couple of problems, so I thought I would see if anyone here in the monastery could give me some advice.

I am trying to scrape a webpage to remove a username and the ip address associated with it. There are multiple username/ip address pairings on the page. This information will then be inserted into a database. The problem that I will run into though is that the same username and ip will undoubtably be on the page more than one time. In order to make sure that only one pairing of information is inserted into the database, wouldn't I want to insert the scraped information into a hash or array before doing a database insert so I could somehow remove duplicates? I am not sure how to go about this.

Do I use a hash, or an array? Can I use a regular expression to add the username ip address pair of data to a hash and then remove duplicates? Is this how it should be done? I am really confused.

I appreciate everyone's help and thanks in advance.

--ghettofinger

In reply to Using hashes or arrays to remove duplicate entries by ghettofinger

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.