Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: perl 5.16.3 + Tk 804.031 core dumps on syntax check when a window is made in BEGIN block

by Anonymous Monk
on Nov 07, 2013 at 00:37 UTC ( [id://1061508]=note: print w/replies, xml ) Need Help??


in reply to Re: perl 5.16.3 + Tk 804.031 core dumps on syntax check when a window is made in BEGIN block
in thread perl 5.16.3 + Tk 804.031 core dumps on syntax check when a window is made in BEGIN block

Earlier use Tk; was already in BEGIN block before the genesis of above test case.

Moving destroy() inside BEGIN does avoid the core dump. Need to have, however, the MainWindow object to live beyond BEGIN block for other things.

# Remove "BEGIN" and get no core dump. BEGIN { use Tk; our $MW = MainWindow->new(); # other method calls. } our $MW; # more changes to the window. # Being here does not avoid core dump. $MW->destroy();
c

Replies are listed 'Best First'.
Re^3: perl 5.16.3 + Tk 804.031 core dumps on syntax check when a window is made in BEGIN block
by MidLifeXis (Monsignor) on Nov 07, 2013 at 15:09 UTC

    BEGIN { use Tk; our $MW = MainWindow->new(); # other method calls. } our $MW;

    Perhaps you mean (not verified):

    our $MW; BEGIN { use Tk; $MW = MainWindow->new(); # other method calls. }
    Declare the window before the BEGIN block, and assign it within the BEGIN block. Update: I stand corrected.

    --MidLifeXis

      # cat x.pl ; perl-5.16.2 x.pl use strict; use warnings FATAL => 'all'; use 5.010; P::show(); Q::show(); R::show(); {{ package P; my $v = __PACKAGE__; BEGIN { $v .= ' ' . __LINE__; } sub show { say $v; } }} {{ package Q; our $v = __PACKAGE__; BEGIN { $v .= ' ' . __LINE__; } sub show { say $v; } }} {{ package R; BEGIN { our $v = __PACKAGE__ . ' ' . __LINE__; } our $v; sub show { say $v; } }} __END__ 13 21 R 28

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1061508]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-19 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found