RE: Module Digest.pm causes error

2010-01-12 Thread Nele Kosog
The constructor of Data::Serializer takes a digester string which is later 
passed on to Digest:
Digest-new($digester); (line 668)

I can't find any use or require statements but I think (correct me if I am 
wrong) Data::Serializer uses this line to load modules: 
eval { require $package }; (line 187)

Since the Digest method is passed as string, I think Data::Serializer uses 
SHA-256 (that's the default and I don't pass a different parameter to 
Data::Serializer).

Command:pp -vvv -x -M Digest::SHA -o my_program.exe my_program.pl
Compiles:   Yes
Runs:   No
Error:  Same as before
--
Command:pp -vvv -x -M Digest -o my_program.exe my_program.pl
Compiles:   Yes
Runs:   No
Error:  Same as before

No, it doesn't work with -M Digest::SHA.

Regards,
Nele


Re: Module Digest.pm causes error

2010-01-12 Thread Roderich Schupp
On Tue, Jan 12, 2010 at 9:37 AM, Nele Kosog k...@sevencs.com wrote:
 Since the Digest method is passed as string, I think Data::Serializer uses 
 SHA-256 (that's the default and I don't pass a different parameter to 
 Data::Serializer).
 ...
 No, it doesn't work with -M Digest::SHA.

Referring to the side note in my last post (sorry didn't realize
the consequences):  par.pl doing

 eval { $Digest::SHA::VERSION };

totally screws Digest's  attempt to autoload Digest::SHA.
Snippet from Digest.pm, $class holds the name of
the actual digester module that we want to use, in your
case Digest::SHA:

no strict 'refs';
unless (exists ${$class\::}{VERSION}) {
eval require $class;
if ($@) {
$err ||= $@;
next;
}
}
return $class-new(@args, @_);

Since par.pl has already been run (from prelude code in the packed
executable that is run before your actual script), the above test
has the side effect of bringing the global variable $Digest::SHA::VERSION
to life (as if you had said package Digest::SHA; our $VERSION; ...).
That variable actually is stored in the strange hash
%{Digest::SHA::} under the key VERSION. Hence the exists()
returns true and Digest skips require Digest::SHA.

So while pp option -M generally works for modules whose usage
goes undetected by both static dynamic (option -x) analysis, in your
case it causes pp to pack the module, but Digest simply fails to load it.

The simplest workaround is for you to explicitly

use Digest::SHA;

somewhere in your script (and then you can forget about -M).

Cheers, Roderich


RE: Module Digest.pm causes error

2010-01-12 Thread Nele Kosog
Thanks for your detailed reply! 

With use Digest::SHA; I can at least compile my program into an executable:

pp -x --gui -o my_program.exe my_program.pl

The executable doesn't run though. The process appears in the Task Managers 
list of processes and then just dies and disappears. No messages, no errors in 
the console window. 

I have the feeling I'm making an obvious, stupid, major mistake. It can't be 
that difficult to create a running executable, can it?

Regards,
Nele




RE: Module Digest.pm causes error

2010-01-12 Thread Nele Kosog
Roderich,

I did it again. Yes, it is an obvious, stupid, major mistake: I forgot to 
update the appropriate module which is in the @INC. When I added use 
Digest::SHA; and recompiled the executable (pp -x --gui -o my_program.exe 
my_program.pl), it all worked well.

Thank you so much for your effort!
Regards,
Nele



Re: Module Digest.pm causes error

2010-01-11 Thread Roderich Schupp
On Mon, Jan 11, 2010 at 1:48 PM, Nele Kosog k...@sevencs.com wrote:
 When running the EXE the program exits with the following error message:

 Can't locate object method new via package Digest::SHA at Digest.pm
 line 43
 (#1)
    (F) You called a method correctly, and it correctly indicated a
 package
    functioning as a class, but that package doesn't define that
 particular
    method, nor does any of its base classes.  See perlobj.

 Uncaught exception from user code:
        Can't locate object method new via package Digest::SHA at
 Digest.pm line 43.

Does this also happen with a minimalist pp'ed executable, e.g.

pp -o hello.exe -e 'print hello\n'
./hello.exe

If this runs OK, does your program (or any modules it uses)
something like

$d = Digest-new(SHA);

Cheers, Roderich