C:\>pp --gui -c par_wrap.pl -a w32_exetype.pl -a w32_mkcons.pl -a main.pl -a other_thing.pl
####
#!/usr/bin/perl -w
# w32_mkcons.pl - Create a console version of the running PAR exe.
# May need to be rerun if the PAR_TEMP is cleared
use File::Copy;
#warn `set`; warn $0; warn $^X;
$ENV{PAR_PROGNAME} or die "$0 only works under PAR";
my ($exe_path, $gui_exe) =
$ENV{PAR_PROGNAME} =~ m{^ (.*[\\/]) (.*)}x;
(my $con_exe = $gui_exe) =~ s/\.exe$/-cons.exe/;
my $gui_par = "$ENV{PAR_TEMP}/$gui_exe";
my $con_par = "$ENV{PAR_TEMP}/$con_exe";
copy("$exe_path$gui_exe" => "$exe_path$con_exe");
copy($gui_par => $con_par);
my @cmd = w32_cmd('w32_exetype.pl'); # needs par_wrap.pl
system(@cmd, $con_exe, 'console');
system(@cmd, $con_par, 'console');
sub w32_cmd {
my $script = shift;
my @cmd;
# Run PAR_PROGNAME exe as the perl/parl interpreter and
# let bin/par_wrap.pl run $script
@cmd = ($ENV{PAR_PROGNAME}, $script);
return @cmd;
}
__END__
####
# par_wrap.pl
# This file is a merging of the stub scripts in PAR::Packer
# in the subs _main_pl_multi and _main_pl_single
# It defaults to running main.pl but if the first arg ends in .pl
# then we look for another script to run
my $file = 'main.pl';
$file = shift if $ARGV[0] =~ /\.pl$/;
my $zip = $PAR::LibCache{$ENV{PAR_PROGNAME}} || Archive::Zip->new(__FILE__);
my $member = eval { $zip->memberNamed($file)
|| $zip->memberNamed("$file.pl")
|| $zip->memberNamed("bin/$file")
|| $zip->memberNamed("bin/$file.pl")
|| $zip->memberNamed("script/$file")
|| $zip->memberNamed("script/$file.pl")
}
or die qq(Can't open perl script "$file": No such file or directory);
PAR::_run_member($member, 1);
__END__