1

我正在尝试使用以下命令(Windows 7 64 位)将 perl 脚本转换为带有 PAR::Packer pp 的可执行文件:

"pp -o teste.exe gmail_att.pl"

但我收到消息:

"# Use of runtime loader module Module::Runtime detected.  Results of static scanning may be incomplete."

我在互联网上搜索此消息但没有成功

剧本:

printf("Iniciando o envio de e-mails... \n");
use strict;
use Try::Tiny;
use IO::All;
use Email::MIME;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP::TLS;
use Spreadsheet::XLSX;
use File::Basename;


my $diretorioScript = dirname(__FILE__);
my $excel = Spreadsheet::XLSX->new( "$diretorioScript\\jofalista.xlsx", );
my $diretorio = "$diretorioScript\\arquivos\\";
my $email = "";
my $nome = "";

opendir(diretorio, "$diretorio");
my @lista = readdir(diretorio);
closedir(diretorio);

foreach my $arquivo(@lista)
{
    $email = "";
    $nome = "";

    if ($arquivo ne "." && $arquivo ne ".."){


        # print $arquivo;

        # rotina para buscar dentro do arquivo xls qual o email 
        # de destino do arquivo

        foreach my $sheet ( @{ $excel->{Worksheet} } ) {
            $sheet->{MaxRow} ||= $sheet->{MinRow};
            foreach my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) {
                $sheet->{MaxCol} ||= $sheet->{MinCol};
                foreach my $col ( $sheet->{MinCol} .. $sheet->{MaxCol} ) {
                    my $cell = $sheet->{Cells}[$row][$col];
                    if ($cell) {
                        #printf( "( %s == %s ) \n", "$cell->{Val}.pdf", $arquivo );                     
                        if("$cell->{Val}.pdf" eq $arquivo){
                            $nome = $cell->{Val};
                            my $emailCell = $sheet->{Cells}[$row][$col+1];
                            $email = $emailCell->{Val};
                            #printf("%s", $email);
                        }
                        #printf( "( %s , %s ) => %s\n", $row, $col, $cell->{Val} );

                    }    
                }
            }
        }
        if($email ne ""){
            printf("Processando o arquivo $arquivo para o email: $email \n");
            # Create and array of email parts. 
            # Here i have 2 attachments ( an image and a pdf file) and a text message.
            my @parts = (
                Email::MIME->create(
                    attributes => {
                        filename     => "$arquivo",
                        content_type => "application/pdf",
                        encoding     => "base64",
                        disposition  => "attachment",
                        name         => "$arquivo",
                    },
                    body => io( "$diretorio$arquivo" )->all,
                ),
                Email::MIME->create(
                    attributes => {
                        content_type  => "text/html",
                    },
                    body => "Ola $nome este é um e-mail teste da JOFA",
                )
            );

            # Create the email message object.
            my $email_object = Email::MIME->create(
                header => [
                    From           => 'marchiore.matheus@gmail.com',
                    To             => $email,
                    Subject        => "Certificado $nome",
                    content_type   =>'multipart/mixed'
                ],
                parts  => [ @parts ],
            );

            # Create the transport. Using gmail for this example
            my $transport = Email::Sender::Transport::SMTP::TLS->new(
                host     => 'smtp.gmail.com',
                port     => 587,
                username => 'marchiore.matheus@gmail.com',
                password => ''
            );

            # send the mail
            try {
                   sendmail( $email_object, {transport => $transport} );
            } catch {
                   warn "Email sending failed: $_";
            };
        }
    }

}

printf("Pressione ENTER para Finalizar... \n");
chomp( my $input = <STDIN> );
4

2 回答 2

0

解决了将文件 (xlsx) 放入 C:\ 并使用 $ENV{HOMEDRIVE} 获取此目录的问题

这个对我有用。

谢谢!

于 2014-07-25T20:14:27.537 回答
0

我在编译期间使用 -x 参数解决了这个问题

"pp -o -x teste.exe gmail_att.pl"

但现在我有另一个问题,我的 exe 访问一个 xlsx 文件,它试图在 exe 中找到它。错误信息:

Iniciando o envio de e-mails... IO error: opening script\jofalista.xlsx for read : No such file or directory at C:/strawberry/perl/vendor/lib/PAR.pm line 636. Cannot open script\jofalista.xlsx as Zip archive at Spreadsheet/XLSX.pm line 33.

于 2014-07-25T12:30:48.070 回答