in reply to url get with string

If $name is just a simple string like you showed, with no special characters, then huck has given you the answer in regards to interpolation in '$name' vs. "$name".

However, if you've got any special characters in that string, they need to be escaped properly. Here's one way with URI:

use URI; my $name = 'xyz&foo=bar'; my $uri = URI->new('https://www.google.com/'); $uri->query_form( name => $name, foo => 'quz', ); print "$uri\n"; __END__ https://www.google.com/?name=xyz%26foo%3Dbar&foo=quz

Replies are listed 'Best First'.
Re^2: url get with string
by bigup401 (Pilgrim) on Mar 23, 2017 at 10:36 UTC

    haukex am using LWP::UserAgent, guys non of idea has worked,most guys dont believe that some url dont accept using string in url they only allow normal form. so u just have to bypass or force it. any better idea i appreciate

        here is a working code, anyone can try

        my $req = HTTP::Request->new(GET => 'https://www.google.com/finance/co +nverter?a=3&from=USD&to=EUR'); $req->content_type('application/json'); my $re = $ua->request($req); $re->content =~ m|<span class=bld>(.+?)</span>|i and $span = $1; $ct = substr($1, 0, -6); print $ct; prints 2.77 according to the currency usd to euro

        but when you try to put amount from string $m = "3";

        https://www.google.com/finance/converter?a=$m&from=USD&to=EUR

        doesn;t work correctly