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

Replies are listed 'Best First'.
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.

      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.
      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