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

Dear Monks, I need to read an img file from the link (http://domain...../xyz.img) and write it as a file. What would be the best way?

Replies are listed 'Best First'.
Re: Reading img file through URL
by kennethk (Abbot) on Jan 21, 2011 at 15:28 UTC
    What have you tried? What didn't work? After nearly 200 posts, you should really be offering more in a question.

    You can grab the image using LWP::UserAgent. You can write the file using open and print after setting binmode on the file handle.

Re: Reading img file through URL
by SuicideJunkie (Vicar) on Jan 21, 2011 at 15:29 UTC

    LWP::Simple + getstore("url"); should be able to do that in a one-liner.

Re: Reading img file through URL
by marto (Cardinal) on Jan 21, 2011 at 15:32 UTC

    Perhaps I don't understand the question but can't you just LWP::Simple and it's getstore method? If you want something else or I have misunderstood what you're trying to do perhaps a better description of what you need to achieve would help.

Re: Reading img file through URL
by JavaFan (Canon) on Jan 21, 2011 at 15:52 UTC
    $ wget http://domain...../xyz.img
    HTH. HAND.
      Seconded. There is no point monkeying around with some other solution when wget just works (on linux). On Windows, you need to supply a wget binary yourself, and on OS X, use curl.
      Finding (and bundling, if you distribute the code) a wget binary is not that big a deal though.
        wget is available for OS X using ports.