Is the module installed?

      Comments Off on Is the module installed?

This is probably well known to Perl programmers who work with the language on a daily basis.  I seem to find myself doing PERL coding now about once every two months, but happened on this and thought I’d share it. 

When you pull down some Perl source from the web, invariably you’ll see that it depends on several different modules.  Here’s a quick way to find out if you have a particular module installed on your development system.  For example, suppose you have source that includes the Net::SMTP module, just enter this on a command line and you’ll see whether it’s already been installed:

$ perl -e “use Net::SMTP”;

If nothing prints, it is installed. 

If a module isn’t installed, the story’s different:

$ perl -e “use Net::StupidModule”;

Can’t locate Net/StupidModule.pm in @INC (@INC contains: /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6 /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl /Network/Library/Perl/5.8.6/darwin-thread-multi-2level /Network/Library/Perl/5.8.6 /Network/Library/Perl /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 .) at -e line 1.
BEGIN failed–compilation aborted at -e line 1.