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

Does anyone know why the following code is not working:

use LWP::Simple; print $content = get("http://www.nhc.noaa.gov/storm_graphics/AT06/refr +esh/AL0606W5+gif/144631W_sm.gif");

The code is supposed to show a graphic image, instead I see nothing but garbled numbers and letters. I would use the module Image::Grab, but the internet server I am using does not have that module.

Edit: g0n - code tags

2006-09-08 Retitled by Corion, as per Monastery guidelines
Original title: 'LWP'

Replies are listed 'Best First'.
Re: showing an image downloaded with LWP::Simple
by Joost (Canon) on Sep 08, 2006 at 18:15 UTC
    It doesn't work for the same reason "cat image.gif" doesn't work: you can't just print a binary file format to the terminal and expect it to show an image.

    Just send the file data to some program that will display the graphics, for instance, if you have image-magick's display program installed:

    use LWP::Simple; open CMD,"|display -" or die "Can't fork display program: $!"; print CMD get("http://www.nhc.noaa.gov/storm_graphics/AT06/refresh/AL0 +606W5+gif/144631W_sm.gif"); close CMD;
      How come Internet Explorer cannot view the image? Thanks for your help.
Re: showing an image downloaded with LWP::Simple
by Fletch (Bishop) on Sep 08, 2006 at 17:59 UTC

    Erm . . . /boggle

    You've retrieved the contents of a GIF file. You print the contents of that GIF file to your terminal / command window / xterm. You see the raw contents of the file. Wherein is the problem (aside from your presumption that Perl would magically display the contents of image files as images when you print them out)?

    A reply falls below the community's threshold of quality. You may see it by logging in.