Depends whether you want to be able to use your global objects from within your END block or not, eh? This was argued back and forth on p5p quite a bit, I think.
I prefer to code like this:
so that I don't have an objects in global variables and I don't have to remember to undef things.#!/usr/bin/perl -w use strict; # use other modules here # global variables here exit( main( @ARGV ) ); # subroutines here sub main { my $object= Widget::->new(); # more code here return 0; }
A much worse problem, IMHO, is that once you get into the global destruction phase, objects are destroyed in some arbitrary order so that Z can be destroyed before X even if X holds a reference to Z. This means that X's destructor may find undef where it expects a reference to Z. This really sucks to me.
- tye (but my friends call me "Tye")In reply to (tye)Re2: Weird perl behavior regarding unloading class modules
by tye
in thread Weird perl behavior regarding unloading class modules
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |