简体   繁体   English

LOWP :: UserAgent中的PAR :: Packer和HTTPS

[英]PAR::Packer and HTTPS in LWP::UserAgent

I have a simple Perl which uses LWP::UserAgent to connect to HTTPS and decode JSON result: 我有一个简单的Perl,它使用LWP :: UserAgent连接到HTTPS并解码JSON结果:

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. 如果我运行Perl脚本,它工作正常。 I packed it with pp: 我用pp包装它:

pp -c -o maker.exe maker.pl

And I get and error if I run maker.exe: 如果我运行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. 运行PP时始终使用-x 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. 添加use warnings并在代码顶部use strict 。查看是否存在任何潜在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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