This got me thinking about how much redundancy there is in urls, 90% start with www, and are .com, plenty of index.htmls out there, cgi-bin etc. If you split the url up and use each part as a key in a multilevel hash perl only stores each unique key once. Searching is fast and you will get no false possitives. Let the code speak ...

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %store; while (<DATA>) { next if /^\s*$/; chomp; s !//!/!g; s !:!!g; my @bits = split /\.|\//; my $key = ( join "}{", @bits); my $do_this = '$store{' . $key . '}++'; eval $do_this; } print Dumper(\%store); __DATA__ http://www.foo.com/this.html http://www.foo.com/index.html http://www.foo.com/that.html http://www.foo.com/cgi-bin/that.cgi http://www.foo.com/cgi-bin/user.cgi http://www.fred.com/index.html http://www.foo.org/index.html # output $VAR1 = { 'http' => { 'www' => { 'foo' => { 'org' => { 'index' => { + 'html' => +1 } }, 'com' => { 'index' => { 'h +tml' => 1 }, 'that' => { 'ht +ml' => 1 }, 'this' => { 'ht +ml' => 1 } } }, 'fred' => { 'com' => { 'index' => { ' +html' => 1 } } } } } };

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Re: Bloom Filter or other mehod to store URL's? by Random_Walk
in thread Bloom Filter or other mehod to store URL's? by Jaap

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.