in reply to Fetching titles and error handling

LWP::UserAgent provides a mechanism to download a file with a callback for the processing. You could do your check in the callback for the first buffer (although a check for the content-type in the headers is a very sane idea, too), and try to pull out the title in this or one of the following buffers.

Unfortunately I don't think there's an easy way to treat the buffer data from the callbacks as an input stream for HTML::TokeParser::Simple, which seems like the most intuitive approach to me.

Sometimes I'm really jealous of the features in other languages. (coroutines, iterators)