Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Base script behavior on presence (or non-) of a module

by Anonymous Monk
on Dec 21, 2011 at 16:54 UTC ( [id://944664]=note: print w/replies, xml ) Need Help??


in reply to Re: Base script behavior on presence (or non-) of a module
in thread Base script behavior on presence (or non-) of a module

Module::Load is core, as is Module::Pluggable

  • Comment on Re^2: Base script behavior on presence (or non-) of a module

Replies are listed 'Best First'.
Re^3: Base script behavior on presence (or non-) of a module
by Eliya (Vicar) on Dec 21, 2011 at 18:31 UTC

    It's perhaps worth pointing out that those weren't core modules in 5.8.x.

    To me, it sounds like the OP is targetting a wide range of installations, trying to settle on the "lowest common denominator". So there might be 5.8 installations among them.

    In other words, in order to not have the program die with "Can't locate Module/Load.pm in @INC ..." on 5.8 installations, the OP would have to first check the classic "built-in" way, i.e. BEGIN { eval {require Module::Load; 1} or ...}, if the module itself is available — and depending on the outcome, possibly do the loading of the other non-core modules the same classic way...

    Just a thought.

      Yeah

      Module::Pluggable was first released with perl v5.8.9

      Module::Load was first released with perl v5.9.4

      Both are available from CPAN :)

Re^3: Base script behavior on presence (or non-) of a module
by tobyink (Canon) on Dec 31, 2011 at 21:05 UTC

    Module::Pluggable does an entirely different job to Class::Load - it searches for (and optionally requires and instantiates) modules with names matching a particular pattern.

    Module::Load does something similar to Class::Load but has less functionality. Class::Load not only provides load_class (equivalent to Module::Load's load function), but also try_load_class and is_class_loaded, load_first_existing_class and load_optional_class which can be pretty handy at times.

    (The difference between try_load_class and load_optional_class is subtle. Both will check whether the class exists, attempt to load it, and return a boolean indicating successfulness. The difference is in how they handle the situation where the module exists, but cannot be loaded - e.g. due to syntax errors - the former just returns false; the latter croaks.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found