How do I get the output of curl into a variable in Perl if I invoke it using backtics?

It probably sends its stuff to stderr. Try

my $foo = `curl yadd yadda 2>&1`;

You also might consider looking at LWP::UserAgent or even LWP::Simple.


What do you really want to do? Use curl at all costs, or grab the contents of a web page?

A more perlish way of doing this (which relies on no external programs that may or may not be installed on the next machine where you need to do this) would be:

use LWP::Simple;

my $content = get("http://stackoverflow.com/questions/1015438/")
   or die "no such luck\n";

If you want to see why the GET failed, or grab multiple pages from the same site, you'll need to use a bit more machinery. perldoc lwpcook will get you started.