http://www.perlmonks.org?node_id=90765

agent00013 has asked for the wisdom of the Perl Monks concerning the following question:

$link = "http://www.something.com/picture.gif"; $link2 = "http://www.something.com/index.html"; $link3 = "http://www.something.com/something/script"; $link4 = "http://www.something.com/directory";
Given these fourlinks, how can I make my script recognize that one is an , one is HTML, one is a script, and one is a directory?

I don't want to use any regex for this (as I've already got some that work, but I'm looking for a simpler approach and it has difficulty working with the third and forth links. note: I don't control these links, only the script).

I know using LWP::Simple and it's head() function I can determine things like file size, etc. What module/function can I use to determine file type? (example: http/text - or whatever format is used)

Originally posted as a Categorized Question.