ViceRaid has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to use a BEGIN block (or something) in a required file to check whether another module's available. If it's not, I'd like to give up processing this file and just return a true value to the require. I'm not really sure how to do it: something like this?
BEGIN { eval "require Maybe::Module"; if ( $@ ) { # don't bother } } # I only want these to be defined if Maybe::Module's available sub foo { ... }
Thanks
ViceRaid
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Aborting loading of file in a BEGIN block
by broquaint (Abbot) on Aug 15, 2003 at 15:33 UTC | |
by ViceRaid (Chaplain) on Aug 15, 2003 at 15:48 UTC | |
by broquaint (Abbot) on Aug 15, 2003 at 16:15 UTC | |
by ViceRaid (Chaplain) on Aug 15, 2003 at 16:36 UTC | |
by broquaint (Abbot) on Aug 15, 2003 at 17:05 UTC | |
|
Re: Aborting loading of file in a BEGIN block
by John M. Dlugosz (Monsignor) on Aug 15, 2003 at 18:57 UTC | |
|
Re: Aborting loading of file in a BEGIN block
by bdimych (Monk) on Oct 20, 2007 at 02:04 UTC |