in reply to Re: Re: Re: Aborting loading of file in a BEGIN block
in thread Aborting loading of file in a BEGIN block
Thanks - that's great. I can see what I want to do now. Actually it's the require STRING flavour I'm dealing with, so it's maybe a bit easier than I thought. All I want to do is to make sure the subs using Maybe::Module don't blow up when called. I'm doing something like:
my $no_go; BEGIN { eval { require Maybe::Module }; if ( $@ ) { $no_go = 1 } } sub my_function { print "I'm the normal definition"; } # ... if ( $no_go ) { # safe definition *my_function = sub { carp "Function not available without Maybe::M +odule" }; } 1;
This works nicely for me; as an aside, I wonder why the BEGIN block can see the my $no_go? I would have expected the BEGIN to run first and so to complain about $no_go failing strict;
Thanks again
ViceRaid
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Re: Aborting loading of file in a BEGIN block
by broquaint (Abbot) on Aug 15, 2003 at 17:05 UTC |