http://qs321.pair.com?node_id=904706

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

Greetings Monks!

I didn't find the answer in 0.2 seconds using the super search, so I'm just asking... is this good or bad lazy? Anyway...

What's the best module if I want my perl script to be able to grab a file when given a URL? I'm hoping for something that will handle all the URL complexity and protocol stuff? I'm thinking one of the many curl libs, but I'm not sure which or if there is something other than curl that might be better? In case I'm not making sense (a common problem) here's what I want to be able to handle:

frobozinate.pl http://example.com/wharg.txt frobozinate.pl ftp://bob:secret@example.com/wharg.txt frobozinate.pl file:///home/bob/wharg.txt

Thanks!
--Pileofrogs

Replies are listed 'Best First'.
Re: Lazy URL question?
by BrowserUk (Patriarch) on May 13, 2011 at 19:19 UTC

    Personally, when I've had occasion to fetch anything bigger than a few 10s of Kbytes on a regular basis, if prefer to shell out to wget.

    It handles most protocols. It gives reliability with its ability to retry many times and pick up from where it left off when things go wrong. I can throttle the transfer if it is likely to impinge upon my other network activities. And has a myriad of other features if I need them.

    As a bonus, it generally runs more quickly than my browser, LWP or any other tools I've tried.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Lazy URL question?
by Anonymous Monk on May 13, 2011 at 18:18 UTC

      Holy crap... LWP really does most of what I want... I can just used a different URL in my existing code! Wow!

Re: Lazy URL question?
by JavaFan (Canon) on May 13, 2011 at 18:16 UTC
    You talk about "better" and "best". Your better isn't my better, and neither is that the better of someone else.

    Unless you give any indication of what measurement you're ranking the modules, your question should be a poll, because all you're getting as answers is peoples favourite tool.

      I guess I'm looking for something popular, as in stable, reliable & usable. I do not care about performance.