listanand has asked for the wisdom of the Perl Monks concerning the following question:
I have a situation where I need to identify whether a URL is a PDF file or not. Here's an example URL : http://ccdl.libraries.claremont.edu/u?/stc,87 Looking at it, it's not obvious that it links to a PDF.
Here's the relevant code snippet. It is not working though.
Thanks in advance.
use MIME::Types;
my $mt = MIME::Types->new;
my $url="http://ccdl.libraries.claremont.edu/u?/stc,87";
if($mt->mimeTypeOf($url) eq "application/pdf"){
print "$url is a PDF file\n";
}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Identifying PDF from URLs
by tinita (Parson) on May 24, 2010 at 23:39 UTC | |
|
Re: Identifying PDF from URLs
by Corion (Patriarch) on May 24, 2010 at 21:35 UTC | |
|
Re: Identifying PDF from URLs
by Your Mother (Archbishop) on May 24, 2010 at 23:53 UTC | |
by tinita (Parson) on May 25, 2010 at 00:19 UTC | |
by listanand (Sexton) on May 25, 2010 at 00:23 UTC | |
|
Re: Identifying PDF from URLs
by aquarium (Curate) on May 24, 2010 at 23:07 UTC | |
|
Re: Identifying PDF from URLs
by JavaFan (Canon) on May 31, 2010 at 11:18 UTC | |
|
Re: Identifying PDF from URLs
by doug (Pilgrim) on May 25, 2010 at 22:48 UTC |