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


in reply to LWP to download images, how to let LWP decide, wether it is an image or not?

hihi.

I haven't tested this yet myself, but since HTTP::Response is a subclass of HTTP::Message, you should be able to:

if ($res->content_type =~ /^image\//) { ...

Replies are listed 'Best First'.
Re: Re: LWP to download images, how to let LWP decide, wether it is an image or not?
by khippy (Scribe) on Oct 20, 2001 at 15:13 UTC
    :-) oneiros, you won the combat :-)
    Since I wanted to avoid an extension test for all possible image file types your knowledge about the LWP-Module and its subclasses fits perfectly. A quick test after implementing the code resulted fine.
    I have updated my scratchpad, if you want to take a look, feel free to do so (and all others, too). Note, that the code is not cleaned up, yet. It's developing code :-)

    --

    there are no silly questions
    killerhippy
Re: Re: LWP to download images, how to let LWP decide, wether it is an image or not?
by Amoe (Friar) on Oct 20, 2001 at 15:09 UTC
    I have tested that, and it is probably the best way to do it.

    --
    my one true love