http://www.perlmonks.org?node_id=166008

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm a newbie to Perl. I have a site with various external URLs in a flat-file database. If I have the URL in a variable in my program, what would I have to do to check the URL to see if it's dead or not? I read through other similar questions. I didn't get it. One, I'm not sure if I have LWP. Two, I just didn't get it. The best I found was this:
use strict; use IO::Socket::INET; for (@ARGV){ s|http://||; m|([^/]+)(.*)|; my $s=IO::Socket::INET->new(PeerAddr=>$1,PeerPort=>80,Proto=>'tcp',Ty +pe=>SOCK_STREAM); print $s "GET ".($2||'/')." HTTP/1.0\nHost: $1 \n\n"; print "Link $_ is validated\n" if <$s>=~/200 OK/; close $s; }
However, I'm clueless as to why it's a for. Also, it looks like it's reading from a default variable and I don't know how to set that. Could anyone explain either what this code is doing (line by line) or give me a better snippet of code? I don't need something that checks many links, just one.