Question

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     => 'my@email.com',
  Password => 'my_password',
  Port     => 993,
  Ssl      =>  1,
  )
  or die "Cannot connect through IMAPClient: $!";
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top