#!/usr/bin/perl
# hacked hastily by olivier thereaux <ot@w3.org) for W3C
# distributed under the W3C software license - hack away!
# http://www.w3.org/Consortium/Legal/copyright-software

use HTTP::Request::Common;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
foreach $my_file_path (@ARGV)
{
    print "Validating $my_file_path ... ";
    my $res = $ua->request(POST 'http://validator.w3.org/check',
    Content_Type => 'form-data', Content      => [uploaded_file   => ["$my_file_path"] ] );
    my $isvalid = $res->header( "X-W3C-Validator-Status" );
    my $haserrors = $res->header( "X-W3C-Validator-Errors" );
    if ($isvalid eq "Invalid") { 
        print "$isvalid - $haserrors error(s) \n";
        #exit 1;
    }
    else {
        print "$isvalid \n";
    }
    sleep(2); # MUST do this - be polite with the validation server
}
#exit 0;


