The database isn't storing the last word it comes across each time through the loop. In fact, the database shows to be empty when I loop through it at the top (commented out now).

For the life of me I can't figure out why the database isn't storing the newest word. I've tried everything. Twice. My only hypothesis is it's not storing because I CTRL+C my way out of the program each time because the dictionary is so large that it'll take quite some time to work through.

Could this be the problem? If so, how could I go about being able to stop the script safely where the database will save the last word?

The dictionary file is not blank. The array is fine. The entire script works properly except for the database. When the script is done, there will be a sleep between each page parse as to be nice to GoDaddy.

Any suggestions?

#!/usr/bin/perl use warnings; use strict; use DB_File; use POSIX; my $dbase = "dbase.db"; my %dbase; tie (%dbase, 'DB_File', $dbase, O_CREAT|O_RDWR, 0644) || die "Died tying database\nReason: $!\n"; my $dict = "dictionary.txt"; my $saved = "saved.txt"; #foreach (keys %dbase) #{ print "$_ => $dbase{$_}\n ."; } #exit; my $search = "https://www.godaddy.com/gdshop/default.asp"; open(DICT, $dict) or die "Cannot open $dict because $!"; my $words = <DICT>; my @words = split(/ /, $words); close(DICT) or die "Cannot close $dict because $!"; if ($ARGV[0] =~ m/con/i) { my $start = $dbase{"word"}; shift @words until $words[0] =~ m/$start/; print "con found!\n"; } my $count = -1; open(SAVED, ">>$saved") or die "Cannot open $saved because $!"; foreach my $word (@words) { $count++; print "Searching $word..\n"; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get($search); $mech->submit_form( form_name => "LookupForm", fields => { domainToCheck => "$word" } ); $dbase{"word"} = "$word"; my $results = $mech->content; if ($results =~ m/This domain name IS AVAILABLE/i) { print SAVED "$word.com\n"; print "\t $word AVAILABLE!\n\a"; } else { print "\t $word TAKEN\n"; } } close(SAVED) or die "Cannot close $saved because $!"; untie %dbase;


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to database not storing data by sulfericacid

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.