Randal Schwartz... cool! Your llama book got me going with Perl, and now you're helping me out on Perl Monks. Thanks!
Anyway... I've pasted my final code below and it works. I was just wondering if there was a more efficient way to do it. Right now I am making two requests for the url. I figure this eats up bandwidth and just plain takes longer. Can someone offer a little input? Thanks!
#!/usr/bin/perl
use LWP::UserAgent;
($ua = LWP::UserAgent->new)->timeout(20);
$url = "http://fly.hiwaay.net/~dbwalker/josie.mp3";
if(($ua->request(HTTP::Request->new('HEAD', $url)))->code() == 200) {
$redirect = $ua->simple_request(HTTP::Request->new('HEAD', $url));
if ($redirect->code == 301 or $redirect->code == 302) {
print "BAD\n";
} else {
print "GOOD\n";
}
} else {
print "BAD\n";
}
|