Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: how to read data from a URL

by Mutant (Priest)
on May 15, 2007 at 08:19 UTC ( #615488=note: print w/replies, xml ) Need Help??

in reply to how to read data from a URL

Hi armenica,

As mentioned above, LWP::Simple will do what you need. But here are a few more tips:
  • It's actually spelt 'Perl' not 'PERL'. It may seem pedantic, but people in the Perl community can get a bit irritated if you get this wrong.
  • In general, Perl prefers to have less functionality in the 'core', and more in loadable modules, as opposed to PHP, which packs all it's functionality into the core. So for example, in PHP you don't have to do anything special to get a remote URL other than call the function, but in Perl you have a few modules to choose from, one being LWP::Simple. There are pros and cons to both approaches, but it can take a while to get used to this in Perl if you've come from PHP. A good place to find the modules, along with their documentation is (CPAN is like PEAR in PHP).
  • If you have content that you need to URI encode, try URI::Escape (another example of where Perl puts functionality into a module rather than has it in the core as PHP does).
  • There are a few places to find Perl's documentation, but one is
Also note that posts on PerlMonks use HTML, so you need to add in linebreaks, etc. It also supports the <code> tags, which make formatting your code much easier. If you wrap your code above in these tags, you'll see what I mean.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://615488]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-10-03 14:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found