in reply to Re: url get with string
in thread url get with string

i tried it bt failed. lets say if the link is like this

$fname = "john"; $lname = "doe"; $ctry = "canada"; my $req = HTTP::Request->new(GET => 'https://www.google.com/?firstname +=$fname&lastname=$lname&country=$ctry')

but works with no $ string

my $req = HTTP::Request->new(GET => 'https://www.google.com/?firstname=john&lastname=deo&country=canada')

Replies are listed 'Best First'.
Re^3: url get with string
by Corion (Patriarch) on Mar 23, 2017 at 09:11 UTC

    Try splitting up your problem in two parts:

    $fname = "john"; $lname = "doe"; $ctry = "canada"; my $url = 'https://www.google.com/?firstname=$fname&lastname=$lname&co +untry=$ctry'; print "Requesting ", $url, "\n"; my $req = HTTP::Request->new(GET => $url);

    Also, you might want to learn about single and double quotes and how they differ in behaviour:

    my $single_quoted = 'https://www.google.com/?firstname=$fname&lastname +=$lname&country=$ctry'; my $double_quoted = "https://www.google.com/?firstname=$fname&lastname +=$lname&country=$ctry"; print 'Single quotes:', $single_quoted, "\n"; print "Double quotes:", $double_quoted, "\n";
Re^3: url get with string
by hippo (Archbishop) on Mar 23, 2017 at 09:11 UTC

    It fails because you are still using single quotes.