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

Gracious Monks,

I'm using the code below to grab a webpage that requires a username and password.

$ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => 'http://webpage/bio/view-sn +p/$snp_number'); $req->authorization_basic('user', 'pass'); print $ua->request($req)->as_string;

The problem as you might well enough see (since perl monks are omniscent) is that my variable is not being interpreted in this context (i have no experience with this code). I was previously using get() which does interpret variable strings.

Not sure what to do so that i can have the variable interpreted.

What do you think?

-herold 'brushing off the cobwebs'

Replies are listed 'Best First'.
Re: User/Pass web page grab with url/$variable interpretation.
by Solo (Deacon) on Feb 21, 2003 at 23:55 UTC
    perlop contains your answer. Single-quotes are not interpolated (usually;). This should work:

    ... GET => "http://webpage/bio/view-snp/$snp_number" ...

    --Solo

    --
    No. I don't think the Empire had Wookiees in mind when they designed her, Chewie.
Re: User/Pass web page grab with url/$variable interpretation.
by dws (Chancellor) on Feb 21, 2003 at 23:58 UTC
    The problem as you might well enough see ... is that my variable is not being interpreted in this context

    You need to use double quotes instead of single quotes in

    $req = HTTP::Request->new(GET => 'http://webpage/bio/viewsnp/$snp_nu +mber');
    Single quotes block variable interpolation.