sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: database not storing data
by Tanktalus (Canon) on Oct 29, 2005 at 03:14 UTC | |
by sulfericacid (Deacon) on Oct 29, 2005 at 04:04 UTC | |
|
Re: database not storing data
by ChemBoy (Priest) on Oct 29, 2005 at 05:01 UTC | |
|
Re: database not storing data
by graff (Chancellor) on Oct 29, 2005 at 19:38 UTC | |
by sulfericacid (Deacon) on Oct 29, 2005 at 20:17 UTC | |
|
Re: database not storing data
by Jenda (Abbot) on Oct 29, 2005 at 21:07 UTC | |
|
Re: database not storing data
by Anonymous Monk on Oct 29, 2005 at 11:21 UTC |