People have tried to explain but we are not getting thru to you, look at this

use strict; use warnings; use LWP; my $ua = new LWP::UserAgent(); { # In this case you have 2 literal strings enclosed in single quotes # with the variable $m concatenated in the middle. # I like that way best because you are assured text is text and variab +les are variables. # my $m=3; my $uri = 'https://www.google.com/finance/converter?a='.$m.'&from=USD& +to=EUR'; my $req = HTTP::Request->new(GET => $uri); $req->content_type('application/json'); my $re = $ua->request($req); $re->content =~ m|<span class=bld>(.+?)</span>|i;# and $span = $1; my $ct = substr($1, 0, -6); print 'ct:'.$ct."\n"; print $uri."\n"; } { # Here you have one string, # but because it is in double quotes perl symbols/expressions get in +terpolated inside. # Some think it is cleaner, # but things you dont expect can change # because perl sees them as something to replace. # my $m=3; my $uri="https://www.google.com/finance/converter?a=$m&from=USD&to=EUR +"; print $uri."\n"; } { # a third way, as suggested by [haukex] # In this case many problems associated with special characters in the + uri are avoided. use URI; my $m=3; my $uri =URI->new('https://www.google.com/finance/converter'); $uri->query_form( a => $m, from => 'USD', to => 'EUR', ); print $uri."\n"; }
Notice how all 3 printed uris are the same and what you want to see
D:\goodies\pdhuck\down1\perl\monks>perl uri.pl ct:2.78 https://www.google.com/finance/converter?a=3&from=USD&to=EUR https://www.google.com/finance/converter?a=3&from=USD&to=EUR https://www.google.com/finance/converter?a=3&from=USD&to=EUR
Do you get it yet? I only ran the first method but sine all 3 printed uris are the same any of the 3 methods would work the same.


In reply to Re^5: url get with string by huck
in thread url get with string by bigup401

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.