For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > March 2004 > how to know if a module is already loaded?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to know if a module is already loaded?
Bunny

2004-03-26, 11:12 pm

How do I test if a particular module is loaded on my system?
Bunny
Martin Vorlaender

2004-03-26, 11:12 pm

Bunny (bunny1112@yahoo.com) wrote:
> How do I test if a particular module is loaded on my system?


That depends on how you interpret that question:

To test whether a module has already been loaded into an application,
consult the %INC hash (where the keys are module_names mangled with
{ $module_name =~ s|::|/|g; $module_name .= '.pm'; } and the value
are the full path to the module).

To test whether a module has been installed, enter

% perl -M<module> -e 1

If you get "Can't locate <module>.pm in @INC (@INC contains ...)"
the module is not installed.

cu,
Martin
--
So long, and thanks | Martin Vorlaender | OpenVMS rules!
for all the books... | work: mv@pdv-systeme.de
In Memoriam Douglas Adams | http://www.pdv-systeme.de/users/martinv/
1952-2001 | home: martin@radiogaga.harz.de
Arthur Corliss

2004-03-26, 11:12 pm

On 2004-03-20, Bunny <bunny1112@yahoo.com> wrote:
> How do I test if a particular module is loaded on my system?


rv = eval "require Module::Foo";

--
--Arthur Corliss
Bolverk's Lair -- http://arthur.corlissfamily.org/
Digital Mages -- http://www.digitalmages.com/
"Live Free or Die, the Only Way to Live" -- NH State Motto
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com