Glad to hear it!
Marto is right about the -x switch; I hadn't yet read that far in the pp docs, but now I see why "pp" would want to run the program first, to further evaluate what other modules (eg. DLLs) are needed.
He's also correct about the cached files, it seems that using the -C (or --clean) switch to "pp" will:
Clean up temporary files extracted from the application at runtime. By
+ default, these files are cached in the temporary directory; this all
+ows the program to start up faster next time.
I'm excited that this new way (for me) of packaging Perl programs seems an elegant (and cheap) alternative to ASP's "perlapp". I tried using it with Tk and it worked very smoothly.
Here's my demo program; you can call it with --exe to build the executable:
##
# PAR::Packer example using Tk
#
# Notes:
#
# 1. Run this script, and it creates a simple Tk App
# 2. Install PAR::Packer in Windows using:
#
# C:\> ppm install MinGW
# C:\> cpanp i PAR::Packer
#
# Don't worry if Win32::Exe tests fail:
#
# dmake.exe: Error code 129, while making 'test_dynamic'
# dmake.exe: Error code @55, while making 'sudirs-test'
#
# Just select 'y' when prompted: Proceed anyway? [y/N]: y
#
# 3. To make the executable, type "<script> --exe"
#
#
###############
## Libraries ##
###############
use strict;
use warnings;
use File::Basename;
use Tk;
##################
## Main program ##
##################
my $src = basename $0;
(my $exe = $src) =~ s/[.]pl$/.exe/;
if (@ARGV > 0 and $ARGV[0] eq '--exe') {
my $cmd = "pp --gui -o $exe $src";
print "Command: $cmd\n";
system($cmd);
exit;
}
# Tk Gui
my $mw = new MainWindow(-title => 'PAR::Packer with Tk Example');
my $frm = $mw->Frame->pack(-expand => 1, -fill => 'both');
my $b1 = $frm->Button(-bg => '#ffefb3', -text => 'Hello World');
my $b2 = $frm->Button(-bg => '#ffefb3', -text => 'Quit (^Q)');
$b1->configure(-command => sub { print "Hello world!\n" });
$b2->configure(-command => sub { exit });
$b1->pack(-side => 'left');
$b2->pack(-side => 'right');
$mw->bind("<Control-q>" => sub { $b2->invoke });
$mw->MainLoop;
say
substr+lc crypt(qw $i3 SI$),4,5
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.