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;
In reply to database not storing data by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |