# The script take the URL list on the command line # So, you should call your script like this : # perl myscript.pl http://site/f1.html http://site/f2.html ... # Command line arguments are stored in the ARGV list. # For each URL in ARGV, place this current URL in $_ # $_ the the "default" variable in Perl. for (@ARGV){ # Remove the leading "http://" part of $_ s|http://||; # Extract the server name in $1 and the file name in $2 # from $_ (see "perlre" documentation for this) m|([^/]+)(.*)|; # Open a tcp socket connection to the server $1 on port 80 my $s=IO::Socket::INET->new( PeerAddr=>$1, PeerPort=>80, Proto=>'tcp', Type=>SOCK_STREAM ); # Send a simple HTTP GET request to the server for # file $2 or "/" if $2 is not defined. print $s "GET ".($2||'/')." HTTP/1.0\nHost: $1 \n\n"; # Read the first line of the answer (with <$s>) from the # server and print "Link xxx is validated" if the server # answered positively to the request (server answers # "HTTP 200 OK" when file is present) print "Link $_ is validated\n" if <$s>=~/200 OK/; # Close the connection close $s; # and treat the next URL }