#!/usr/bin/perl -- # -*- Perl -*- use LWP::UserAgent; my $file = shift @ARGV; my $uri = shift @ARGV; #print STDERR "Comparing $file to $uri\n"; my ($actual, $expected); open (F, $file); read (F, $actual, -s $file); close (F); my $ua = new LWP::UserAgent; my $req = new HTTP::Request GET => $uri; my $res = $ua->request($req); $expected = $res->content(); # Finesse whitespace after the XML declaration, if we can $actual = $1 . $2 if $actual =~ /^(<\?xml.*?\?>)\s*(.*)$/s; $expected = $1 . $2 if $expected =~ /^(<\?xml.*?\?>)\s*(.*)$/s; #print STDERR "E: $expected\n"; #print STDERR "A: $actual\n"; if ($expected eq $actual) { exit 0; } else { exit 1; }