简体   繁体   中英

PAR::Packer and HTTPS in LWP::UserAgent

I have a simple Perl which uses LWP::UserAgent to connect to HTTPS and decode JSON result:

my $self = shift;
my $text = shift;
my $ua = new LWP::UserAgent;
my $response = $ua -> get ($self -> getReqLink($text));
$response = parse_json($response -> decoded_content);
return decode('utf-8', $response -> {text} -> [0]);

It works fine if I run Perl script. I packed it with pp:

pp -c -o maker.exe maker.pl

And I get and error if I run maker.exe:

JSON error at line 1, byte 1/170: Unexpected character 'S' parsing initial state: expecting whitespace: '\n', '\r', '\t', ' ' or start of an array or object: '{', '[' at Translation/YandexTranslator.pm line 30.

What's wrong?

  1. Always use -x when you run PP. It will add run-time dependencies and generate a more reliable executable for you. In my experience, this option can fix many mysterious errors.
  2. Add use warnings and use strict at the top of your code.See if there is any potential problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM