in reply to LWP: transfer from Python to Perl

it does not work

Sure it does. You've just forgotten to use the relevant modules. If we add those three important lines to the start of your code it does indeed run fine to completion.

use JSON; use Encode; use LWP::UserAgent; # Original content follows, unedited my @data = (); my $json_data = encode_utf8(encode_json(\@data)); my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new(POST => $url2); $request->header("__atts" => $ajax_atts); $request->header('__ath' => $ajax_ath); $request->header('__atcrv' => $ajax_atcrv); #$request->content($json_data); my $response = $ua->request($request);

"It doesn't work" is as useful to a developer as "I'm ill" is to a medic. Try to be specific. SSCCE is best.

Replies are listed 'Best First'.
Re^2: LWP: transfer from Python to Perl
by haj (Vicar) on Jan 10, 2018 at 14:56 UTC
    Provided that the relevant modules happen to be available at runtime, there's also a comment sign preventing the JSON data to be included with the request. So, if "does not work" means "doesn't send JSON data" then just get rid of the # sign.