marchiore has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to convert a perl script to a executable file with PAR::Packer pp with the command (Windows 7 64 bits):

"pp -o teste.exe gmail_att.pl"

but i'm receiving the message:

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

I search for this message on the internet but without success The script:

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.x +lsx", ); 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->{Max +Col} ) { 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 J +OFA", ) ); # 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->n +ew( host => 'smtp.gmail.com', port => 587, username => 'marchiore.matheus@gmail.com', password => '' ); # send the mail try { sendmail( $email_object, {transport => $transpo +rt} ); } catch { warn "Email sending failed: $_"; }; } } } printf("Pressione ENTER para Finalizar... \n"); chomp( my $input = <STDIN> );

Replies are listed 'Best First'.
Re: Convertion Perl Script to Exe with PAR::Packer pp
by marto (Cardinal) on Jul 24, 2014 at 20:59 UTC
Re: Convertion Perl Script to Exe with PAR::Packer pp
by AppleFritter (Vicar) on Jul 24, 2014 at 21:04 UTC

    Email::Sender::Simple uses MooX::Types::MooseLike::Base, which uses Moo, which uses Module::Runtime. So pp is simply telling you that your script might use extra modules it cannot know about. (Indeed, cannot know about; I'm quite sure that determining precisely which modules a script uses in the presence of modules loaded at runtime without actually running the script and exercising all possible code paths would be equivalent to solving the halting problem.)

      As long as a module or library doesn't "compute" what else it needs to load at run time, it is possible to statically inspect each module and library loaded to find what they load. Then scan all those and so on, until you run out of "new" modules and libraries.

      As I understand it, the scanner used by PAR::Packer only scans Perl modules. If the libraries loaded by any of these modules load further libraries (and maybe even modules), it won't see them. So, pp has the -c and -x options to help.

      -c tells it to compile the input. This runs each module's setup code, as well as any BEGIN, UNITCHECK and CHECK blocks (see BEGIN). This updates information in the Perl environment that the scanner can inspect for more libraries and modules.

      -x actually runs the inputs, but without parameters or options1. This might find even more then -c, but some programs might not work properly when run this way.

      YMMV applies.

      1 In the past, I've had problems with programs that, correctly, exit with a non-zero status when run with no parameters or options. I and others have requested either a way to specify parameters/options or to otherwise detect when being run by the PAR::Packer scanner. Maybe this will happen.

      Update: Or to add an option to ignore the program's exit status.

      In the meantime, possible work-arounds include do a test run with a modified version of your program, or "enhance" your program to check for a value in an environment variable you set before running pp/PAR::Packer (actually, the ability to accept options through an environment variable may, in some cases, be a desirable feature)

        Thanks, executing with -x resolved this problem but my script access the xlsx file so when i run the exe file generated by pp i have the error:

        Iniciando o envio de e-mails... IO error: opening script\jofalista.xlsx for read : No such file or dir +ectory at C:/strawberry/perl/vendor/lib/PAR.pm line 636. Cannot open script\jofalista.xlsx as Zip archive at Spreadsheet/XLSX.p +m line 33.
        note: while pp is converting the program works fine, the problem happens when i'm execute de file exe.