1: #!/usr/bin/perl
   2: # File to check
   3: $fileToCheck = @ARGV[0];
   4: print "Check HTTP File\n";
   5: # Create an agent
   6: use LWP::UserAgent;
   7: $ua = new LWP::UserAgent;
   8: $ua->agent("PerlMonks Webbot /1.1.1" . $ua->agent);
   9: 
  10: # Create a request
  11: my $req = new HTTP::Request HEAD => $fileToCheck;
  12: 
  13: # Pass request to the user agent and get a response back
  14: my $res = $ua->request($req);
  15: if ($res->is_success) {
  16:         print "file $fileToCheck exists\n";
  17: } else {
  18:         print "file $fileToCheck doesn't exist\n";
  19: }                                                  
  20: exit;