Perl PP 正在 /script/ 内搜索输出脚本

发布于 2024-12-28 16:42:47 字数 1066 浏览 1 评论 0原文

我有一个非常奇怪的问题,但只有在运行 Ubuntu 时(在 CentOS 上一切正常)。 我用 Perl 编写了一个脚本,并使用了 Mail::IMAPClient 模块。

当我运行以下命令时:

pp -o myapp perlscript.pl

一切正常,但是当我尝试执行二进制脚本(myapp)时,它给出以下错误:

Cannot connect through IMAPClient: No such file or directory at script/perlscript.pl line 22.

但是当我运行 perlscript.pl 时一切正常...... ..
你知道为什么吗?

脚本:

#!/usr/bin/perl

use strict;
use Mail::IMAPClient;
use Data::Dumper;
use MIME::QuotedPrint ();

$|=1;

# Vars
my $odate = `date +'%d/%m/%Y'`; chomp($odate);
   $odate = '15/01/2012';
my $timeout = 120;

# Connect to IMAP server
my $imap = Mail::IMAPClient->new(
  Server   => 'imap.gmail.com',
  User     => '[email protected]',
  Password => 'my_password',
  Port     => 993,
  Ssl      =>  1,
  )
  or die "Cannot connect through IMAPClient: $!";

I have a really strange problem but only when running Ubuntu ( on CentOS evertyhing is working ).
I've made a script in Perl and used the Mail::IMAPClient module.

When I run the following command:

pp -o myapp perlscript.pl

Everything is working, but when I'm trying to execute the binary script (myapp), it gives me the following error:

Cannot connect through IMAPClient: No such file or directory at script/perlscript.pl line 22.

But when I'm running the perlscript.pl everything is OK ......
Do you have any idea why?

script:

#!/usr/bin/perl

use strict;
use Mail::IMAPClient;
use Data::Dumper;
use MIME::QuotedPrint ();

$|=1;

# Vars
my $odate = `date +'%d/%m/%Y'`; chomp($odate);
   $odate = '15/01/2012';
my $timeout = 120;

# Connect to IMAP server
my $imap = Mail::IMAPClient->new(
  Server   => 'imap.gmail.com',
  User     => '[email protected]',
  Password => 'my_password',
  Port     => 993,
  Ssl      =>  1,
  )
  or die "Cannot connect through IMAPClient: $!";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

私野 2025-01-04 16:42:47

您以错误的方式进行错误检查。 您必须检查 $@,而不是 $!,对于构造函数。运行修改后的程序(尚未用 pp 编译)会给出有用的错误消息:

无法通过 IMAPClient 连接:无法连接到 imap.gmail.com:无法加载“IO::Socket::SSL”:无法在 @INC 中找到 IO/Socket/SSL.pm(@INC 包含: …) 在 (eval 7) 第 2 行。

似乎您忘记告诉编译器 添加隐藏依赖项其中它无法自行检测。

You are doing the error checking wrong way. You must inspect $@, not $!, for the constructor. Running the modified program (not yet compiled with pp) gives the useful error message:

Cannot connect through IMAPClient: Unable to connect to imap.gmail.com: Unable to load 'IO::Socket::SSL': Can't locate IO/Socket/SSL.pm in @INC (@INC contains: …) at (eval 7) line 2.

It seems like you forgot to tell the compiler to add the hidden dependency which it could not detect on its own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文