Tell me, please, a function in perl, similar to that of js,
as encodeURIComponent . That is, in js we write:

 var t = encodeURIComponent(document.title); 

And in perl you should write:

 $t = xyz($title); 

What perl function will this xyz ?

In JS we compile a link like this:
http://connect.mail.ru/share?url='+encodeURIComponent(location.href)+ '&title='+encodeURIComponent(document.title));

What about perl?

    2 answers 2

    That is, on CPAN and in Google banned completely? The first link: URI :: Escape

    • Thank you very much for URI :: Escape! It would have immediately said. - welcomemyaltai
    • HashCode Developers! Red card for those who mention Google! Stay out of work! - welcomemyaltai
    • @welcomemyaltai should be issued a red card to those who do not know how to use Google and ask such questions. Nothing personal, it's just that there is no kindergarten, but one of the most important skills of a programmer is to find the information yourself. - Sh4dow pm
    • Spies from Google in your head. It doesn't matter to me, even though Yandex, even Yakh, even though the search for mail. It is not for missile defense, but not for creche. The opinion of the administration Do everything possible yourself. Before asking a question, try to explore the subject area and find the answer to the question. If a solution cannot be found, provide a brief summary of attempts to solve the problem. Thus, forum participants will be spared the need to search for information on the topic and will be able to focus on the main thing - the answer to the question. - Sh4dow
    • Through the search I found solutions, such as in the second answer, that is, through a regular expression. Here I wanted to ask exactly the function. And the first answer gave a hint: #! / Usr / bin / perl use strict; use URI :: Escape; # ... $ t = uri_escape ($ page_title); $ u = uri_escape ($ page_url); print " connect.mail.ru/share?url=$u&title=$t "; - welcomemyaltai
     s/([^a-zA-Z0-9_.,-])/uc sprintf("%%%02x",ord($1))/eg; 
    • one
      Then too: s / ([^ A-Za-z0-9_. ~ -]) / sprintf ('%%% 02X', ord ($ 1)) / ge; According to RFC-3986 or RFC-3987 symbol ',' needs to be escaped, and '~' is not - chernomyrdin
    • And on CPAN it is proposed: $ string = ~ s /% ([0-9A-fa-f] {2}) / chr (hex ($ 1)) / eg; isn't it? - welcomemyaltai
    • this is unescape. - nörbörnën 2:44 pm