Jan Jaap has asked for the wisdom of the Perl Monks concerning the following question:

Hi I'm not sure how to post this as I'm new to scripting and to using Perl. I want to make a Perl script that:

1. Opens a text document with a huge list of names in it

2. Checks these names on a website to see if they are available to take

3. If they are available to take, it should print it out to let me know I can take it

This is what I have got so far but I'm stuck. The script doesn't give me any errors but it doesn't print out anything either!

http://pastebin.com/ufrU2Lg2

Thanks for the help!

Oh yeah, I know I misspelled "AVALIBLE" but it's misspelled on the website aswell.

Replies are listed 'Best First'.
Re: What is the problem with my script?
by ww (Archbishop) on Dec 17, 2011 at 21:56 UTC
    Please post ALL the information relevant to your post here; not on pastebin. Edit it into the original (and make a note that you've done so inside the OP).

    Please read Markup in the Monastery for advice on formatting.

    Please read How do I post a question effectively? and/or How do I post a question effectively? and/or I know what I mean. Why don't you? for more information on what constitutes a good-faith effort to post a question -- which is tantamount to asking others to spend their time providing that help.

    Update: And come to think of it, I'm not sure how much stock I'd put in offerings from a website that misspells "available" nor offers any insight into how the information is obtained. IMO, http://rscript.org/lookup.php?type=namecheck&name=foo.com was far-too-fast to have done any realtime checking with registrars, whois, or anything much else.

      Good catch in your update - I fed it a domain I own and got:

      START NAMECHECK: AVALIBLE END

      (moments later) Hitting the URL without any parameters - http://rscript.org/lookup.php - yields

      START ERROR: ?type= stats || rank || top10 || players || rscplayers || rskb +|| ge || gers || geupdate || getop || bash || qdb || youtubeinfo || ytinfo || urban || halo3 || reach || activity || track +|| trackrank || trecord || tcompare || gcalc || weather || wowitem || wow || clan || rsforums || spell || namecheck || loginnamec +heck || rsnews || alog || bing || ipdns || drops || wp || questxp || fml || mlia || tfln || translate please. ERROR: This script is partially by micksam7, or at least maintained ev +ery so often. In any case: Please don't eat the fish. NOTICE: Please don't flood this script or use for purposes against Run +eScape Rules. Your ip is sent in the user-agent and x-forwarded-for o +f our script. NOTICE: It'd be really cool if you acknowledge RScript if you use thes +e scripts <3 Really really cool <333333 END
      So it's not a domain availability check; player-name would be my guess.

Re: What is the problem with my script?
by keszler (Priest) on Dec 17, 2011 at 22:32 UTC

    Your code, fixed:

    #!/usr/bin/perl -w use strict; use warnings; use LWP::Simple; my $data_file="common.txt"; open DAT, '<', $data_file || die "Could not open file!"; my @raw_data=<DAT>; close(DAT); # set once outside loop, not each time around my $url = 'http://rscript.org/lookup.php?type=namecheck&name='; foreach my $name (@raw_data) { chomp $name; #my $name = $name; # ??? set above #print "$url$name\r\n"; #my $content = ("GET", '$url$name'); get is a function from LWP::Sim +ple #my $content = ("GET", '$url$name'); $url$name in single quotes is t +hat exact text my $content = get("$url$name"); die "Couldn't get $url$name" unless defined $content; if($content =~ "NAMECHECK: NOTAVALIBLE") { print "\"$name\" is niet beschikbaar\n"; } if($content =~ "NAMECHECK: AVALIBLE") { print "\"$name\" is beschikbaar\n"; } } __END__ "jj" is niet beschikbaar "jakejake" is niet beschikbaar "blowmeuptom" is beschikbaar "bilderberger" is niet beschikbaar "rothchild" is niet beschikbaar "ronaldmcdonald" is niet beschikbaar

      Thanks for the help everyone. It's indeed a player name checker and not a domain checker. I'll try out the edited code someone posted. Thanks!