On 25 Feb 2005 at 12:38, the.noonings wrote:
> I am getting the same problem that is being reported at URL
> http://perlmonks.thepen.com/433411.html
> with subject title
> Problems with pp (Perl Packager)
> I let them know I was here going to post a sample script that duplicates
> the problem.
>
> I am getting the same message
> "BEGIN failed--compilation aborted at -e line 835"
>
It's the same last message at the end of the error messages only because his
error and
yours ultimately cause a "die" at the end of par.pl at line 835. I have no idea
right
now what his error is. Posix has been a bit of a problem for PAR in several
ways.
Autrijus may know what's happening there.
Your problem is a variation on a Tk problem I thought I fixed a while ago.
> I am using Mandrake Linux, perl 5.8.6 and par 0.87
> It runs fine as a perl file.
>
> There are two files below.
> test_tk_129.pl
> Invokes tk_utils to pop up a simple button.
> Prints hello.
> tk_utils.pm
> Pops up a "Click me" button and returns.
> It runs fine using
> "perl test_tk_129.pl"
> I do
> pp -o test_129 test_tk_129.pl
> and then run
> ./test_129
> and I get these results:
> main says hello
> _TK_EXIT_(129)
> BEGIN failed--compilation aborted at -e line 835.
>
This happens because Tk overrides the core "exit" with it's own exit routine;
When
wrapped inside PAR's evaluation, your exit looks like an error and PAR dies at
the end
of it's BEGIN section (which is almost all of par.pl).
There is a check for that right at the end of par.pl, which used to catch
all/most/usual cases of Tk and switched back to the CORE::exit. I suspect that
_TK_EXIT_ has changed it's behaviour in the later Tk versions, since it seems
to be
exiting right out of the program before hitting that error trap now.
> ---------------------------------Paste of test_tk_129.pl
> #!/usr/local/bin/perl -w
> use tk_utils;
> tk_utils::debug_test_1;
> print "main says hello\n";
> exit(129);
>
> -------------------------------End paste of test_tk_129.pl
>
> -------------------------------Paste of tk_utils.pm
> #!/usr/local/bin/perl -w
> package tk_utils;
> use Exporter;
> @ISA = qw(Exporter);
> @EXPORT = ( "debug_test_1" );
>
> use Tk;
> use strict;
>
> sub okay_response {
> my ($we_top) = @_;
> $we_top->destroy;
> }
>
> sub debug_test_1 {
> my $okay_button;
> my $we_top = new MainWindow;
>
> $okay_button =
> $we_top->Button( -text => "Click Me",
> -command => [ \&okay_response,
> $we_top,
> ]
> )->pack(-ipadx =>10);
> #########
> MainLoop;
> #########
>
> }
>
> ------------------------------End paste of tk_utils.pm
>
>
> ----------------------------Paste of notes after further testing
>
> I need to have an exit(129) statement in my real code, so I am keeping
> it in this little test. If I remove the exit(129) statement, THE
> PROBLEM GOES AWAY. If I have just "exit;" the problem comes back.
>
> Again, my real code must be able to tell the caller that it has exited
> with an error code.
>
> Thanks
>
>
Until the new behavior is figured out and bypassed, you can do:
CORE::exit(129);
in your code to avoid the problem. As long as you've done all your widget
cleanup
already, it should be OK.
Or if you can arrange to do your exit from the Tk callback routine, that seems
not to
generate an error, but I don't know why it's different. Maybe because it hasn't
fallen
thru MainLoop yet.
test_tk_129.pl:
#!/usr/local/bin/perl -w
use Tk;
use tk_utils;
print "main says hello\n";
tk_utils::debug_test_1;
tk_utils.pm:
#!/usr/local/bin/perl -w
package tk_utils;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = ( "debug_test_1" );
use Tk;
use strict;
sub okay_response {
my ($we_top) = @_;
$we_top->destroy;
exit(129);
}
sub debug_test_1 {
my $okay_button;
my $we_top = new MainWindow;
$okay_button =
$we_top->Button( -text => "Click Me",
-command => [ \&okay_response,
$we_top,
]
)->pack(-ipadx =>10);
#########
MainLoop;
#########
}
Alan Stewart