LWP-problems

Discussion in 'Perl Misc' started by Ronny Mandal, Dec 13, 2005.

  1. Ronny Mandal

    Ronny Mandal Guest

    Hello.

    I am running the latest ActivePerl on Win32. I utilize the LWP::Simple
    and it's get to fetch images from the web.

    However, on UNIX, it fetches binary, but on Windows it seems like the
    transfer is ASCII. I cannot find anything about the change of mode in
    the doc, anyone knows?


    Thanks,

    Ronny Mandal
     
    Ronny Mandal, Dec 13, 2005
    #1
    1. Advertising

  2. Ronny Mandal

    Guest

    Ronny Mandal wrote:
    anyone knows?

    We can guess all day. Show us some code!
     
    , Dec 13, 2005
    #2
    1. Advertising

  3. Ronny Mandal

    Sisyphus Guest

    "Ronny Mandal" <> wrote in message
    news:...
    > Hello.
    >
    > I am running the latest ActivePerl on Win32. I utilize the LWP::Simple
    > and it's get to fetch images from the web.
    >
    > However, on UNIX, it fetches binary, but on Windows it seems like the
    > transfer is ASCII. I cannot find anything about the change of mode in
    > the doc, anyone knows?
    >


    Just binmode the filehandle before you write what you get() to file:

    use warnings;
    use strict;
    use LWP::Simple;

    my $url = "http://www.kalinabears.com.au/ameliagall.jpg";

    my $content = get($url);

    open(WR, ">pic.jpg") or die "Can't open file for writing: $!";
    binmode(WR);
    print WR $content;
    close(WR) or die "Can't close file after writing: $!";

    __END__

    Cheers,
    Rob
     
    Sisyphus, Dec 13, 2005
    #3
  4. Ronny Mandal

    John Bokma Guest

    Ronny Mandal <> wrote:

    > Hello.
    >
    > I am running the latest ActivePerl on Win32. I utilize the LWP::Simple
    > and it's get to fetch images from the web.
    >
    > However, on UNIX, it fetches binary, but on Windows it seems like the
    > transfer is ASCII. I cannot find anything about the change of mode in
    > the doc, anyone knows?


    Script (bare minimum that has this problem)?

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    I ploink googlegroups.com :)
     
    John Bokma, Dec 13, 2005
    #4
  5. Ronny Mandal

    Bart Lateur Guest

    Ronny Mandal wrote:

    >However, on UNIX, it fetches binary, but on Windows it seems like the
    >transfer is ASCII. I cannot find anything about the change of mode in
    >the doc, anyone knows?


    I'm guessing the server wrongfully describes the content type as text.

    If all's well on the server side, LWP always does the right thing, at
    least in my experience.


    --
    Bart.
     
    Bart Lateur, Dec 13, 2005
    #5
  6. Ronny Mandal

    Ronny Mandal Guest

    On Tue, 13 Dec 2005 12:49:31 +1100, "Sisyphus"
    <> wrote:

    >
    >"Ronny Mandal" <> wrote in message
    >news:...
    >> Hello.
    >>
    >> I am running the latest ActivePerl on Win32. I utilize the LWP::Simple
    >> and it's get to fetch images from the web.
    >>
    >> However, on UNIX, it fetches binary, but on Windows it seems like the
    >> transfer is ASCII. I cannot find anything about the change of mode in
    >> the doc, anyone knows?
    >>

    >
    >Just binmode the filehandle before you write what you get() to file:

    Yes! The binmode really did the trick. Just the same as when emitting
    pictures from .pl



    >
    >use warnings;
    >use strict;
    >use LWP::Simple;
    >
    >my $url = "http://www.kalinabears.com.au/ameliagall.jpg";
    >
    >my $content = get($url);
    >
    >open(WR, ">pic.jpg") or die "Can't open file for writing: $!";
    >binmode(WR);
    >print WR $content;
    >close(WR) or die "Can't close file after writing: $!";
    >
    >__END__
    >
    >Cheers,
    >Rob
    >



    Thanks, Rob!

    -Ronny Mandal
     
    Ronny Mandal, Dec 13, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cp
    Replies:
    3
    Views:
    6,097
  2. Tommy
    Replies:
    0
    Views:
    1,056
    Tommy
    Sep 22, 2003
  3. Mike

    LWP problems

    Mike, Jul 11, 2005, in forum: Perl Misc
    Replies:
    0
    Views:
    87
  4. stephenc

    problems with LWP & HTTP

    stephenc, Aug 14, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    140
    stephenc
    Aug 28, 2007
  5. Dan Rawson

    LWP problems with authenticating proxy

    Dan Rawson, Oct 15, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    252
    Paul Lalli
    Oct 19, 2007
Loading...

Share This Page