in reply to Re: WWW::Curl help
in thread WWW::Curl help

Easy there, no need to be so hurtfull! :P hehe

I understand what libcurl is and what WWW::Curl is. I am also reading the tutorial you are refering to and have got something running, although not with the desired results. I ll read and see what a Callback function is in computer science. Thank you for your reply :)

Finally, are you saying your services are up for hire? :)

Replies are listed 'Best First'.
Re^3: WWW::Curl help
by jethro (Monsignor) on Aug 22, 2008 at 13:06 UTC

    The best phrase I can think of to describe what a callback is is this well known snippet ;-) :

    Don't call us, we call you

    A callback is a subroutine that isn't called directly by some code (the caller), but given as parameter to some other code/subroutine/process (the called), which eventually calls (back) that subroutine.

    Look at sort() in perl. The comparision function you can give to sort is essentially a callback. You never call it yourself, sort calls it when it needs to. Callbacks are most commonly used in window managers where the callbacks react to asynchronous events like key presses and mouse clicks.

      best phrase

      I heard this title of a jazz song lastnight.....

      "If You See Kay"

      if ( uc( k){ \&callback }

      Oh...Fridays :-)


      I'm not really a human, but I play one on earth Remember How Lucky You Are
Re^3: WWW::Curl help
by Anonymous Monk on Aug 22, 2008 at 11:16 UTC
    :) Here's my adaptation minus the callback, untested
    #!/usr/bin/perl -T -- use strict; use warnings; use WWW::Curl 4.05; # otherwise no WRITEDATA, other bugs ... use WWW::Curl::Easy; { my $curl = WWW::Curl::Easy->new(); my $ftpfile = 'README.curl'; if( $curl ){ $curl->setopt(CURLOPT_URL, "ftp://ftp.sunet.se/pub/www/utilities/curl/README.curl"); $curl->setopt(CURLOPT_WRITEDATA,$ftpfile); $curl->setopt(CURLOPT_VERBOSE,1); my $retcode = $curl->perform(); if ($retcode != 0) { warn "An error happened: ", $curl->strerror($retcode), " ( +$retcode)\n"; warn "errbuf: ", $curl->errbuf; } # redundant since $curl goes out of scope $curl->curl_easy_cleanup; } else { warn "DARN, , WWW::Curl::Easy->new() failed"; } } __END__ # ppm install WWW::Curl # ppm install http://theoryx5.uwinnipeg.ca/ppms/WWW-Curl.ppd # http://curl.haxx.se/libcurl/c/ # http://curl.haxx.se/libcurl/c/libcurl-tutorial.html # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html # http://curl.haxx.se/libcurl/c/curl_easy_perform.html # http://curl.haxx.se/lxr/source/docs/examples/ftpget.c # http://cool.haxx.se/cvs.cgi/*checkout*/curl/docs/examples/ftpget.c?r +ev=1.8&content-type=text/plain # http://cool.haxx.se/cvs.cgi/*checkout*/curl/docs/examples/ftpget.c?r +ev=HEAD&content-type=text/plain # http://search.cpan.org/src/SZBALINT/WWW-Curl-4.05/t/01basic.t