#!/usr/bin/perl
my %hostnames;

opendir CACHEDIR,"./Cache/";
@cachefiles = grep { /^[a-zA-Z0-9_]/ && !-f "$_" } readdir(CACHEDIR);
closedir CACHEDIR;
push(@cachefiles,"../bookmarks.html");
push(@cachefiles,"../history.dat");
foreach(@cachefiles)
{
print "./Cache/$_\n";
  open(CACHE,"<./Cache/$_");
  while (<CACHE>)
  {
    if ($_ =~ /:\/\//)
    {
      my $href;
      ($href) = /:\/\/([a-zA-Z\.\-0-9]*)/;
      while ($href ne "")
      {
        $hostnames{$href}++;
        $_ =~ s/:\/\/([a-zA-Z\.\-0-9]*)//;
        ($href) = /:\/\/([a-zA-Z\.\-0-9]*)/;
      }
    }
  }
  close(CACHE);
#    print "$dir/$_\n";
}
open(HOSTNAMES,">hostnames.txt");
while(($hostname,$count)=each %hostnames)
{
  print HOSTNAMES "$hostname\n";
}
close(HOSTNAMES);

