in reply to Re: Re: Aborting loading of file in a BEGIN block
in thread Aborting loading of file in a BEGIN block
Now in the event of the failure to require the given module the current package will be deleted in it's entirety. If the current package is main or someone else's package, then stick a package Other::Package::__temp at the top and export the subroutines upon success e.gBEGIN { eval { require Maybe::Module }; $::SPLAT = 1 if $@; } ## *right* at the end of the file if($::SPLAT) { require Symbol and Symbol->import('delete_package'); delete_package(__PACKAGE__); } 1;
That will export the globs in the current package to the caller's package, which should do the trick.package Other::Package::__temp; BEGIN { eval { require Maybe::Module }; $::SPLAT = 1 if $@; } ## *right* at the end of the file if($::SPLAT) { require Symbol and Symbol->import('delete_package'); delete_package(__PACKAGE__); } else { @{caller()."::"}{keys %{__PACKAGE__."::"}} = values %{__PACKAGE__."::"}; } 1;
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Aborting loading of file in a BEGIN block
by ViceRaid (Chaplain) on Aug 15, 2003 at 16:36 UTC | |
by broquaint (Abbot) on Aug 15, 2003 at 17:05 UTC |