Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: URI::Escape::escape_char error when posting to a form inside perl script

by kcott (Abbot)
on Jan 31, 2013 at 05:59 UTC ( #1016222=note: print w/ replies, xml ) Need Help??


in reply to URI::Escape::escape_char error when posting to a form inside perl script

G'day marknher,

Welcome to the monastery.

According to the HTTP::Request::Common documentation, the request() method, when used with POST, takes its list of key-value pairs as an arrayref:

use HTTP::Request::Common; $ua = LWP::UserAgent->new; $ua->request(POST 'http://somewhere/foo', [foo => bar, bar => foo]);

You're using a hashref (\%Fields). I'd suggest changing your request() call to:

my $Page = $Browser->request(POST $URLtoPostTo, [%Fields]);

-- Ken


Comment on Re: URI::Escape::escape_char error when posting to a form inside perl script
Select or Download Code
Re^2: URI::Escape::escape_char error when posting to a form inside perl script
by marknher (Initiate) on Jan 31, 2013 at 06:15 UTC
    Thank you Ken, I've updated my code to include [] around %fields. Unfortunately, the error remains. From what I can tell, it's because the scalars in the pairs have reserved characters such as @, etc. Any other ideas? Thanks, Mark T.
      If I comment out one of the key-pairs that have a reserved character such as $email (which has @ in it) then the script works fine. Thanks, Mark

      Take a look at the code for URI::Escape which you'll probably find at /usr/local/share/perl/5.10.1/URI/Escape.pm. In the current source for this module, escape_char() is coded right at the end:

      ... sub escape_char { return join '', @URI::Escape::escapes{$_[0] =~ /(\C)/g}; } 1;

      If it's not there, you'll need to ask your server administrators to update their code. If it is there, please show the actual code you are running, i.e. with the calls to uri_escape() - the problem may lie with your implementation.

      -- Ken

        Thanks Ken, This would explain it. I put in the request to the support site for my host and we'll see. Thanks, Mark T.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-07-30 23:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls