Adding Perl modules to OS X Lion with Terminal and CPAN.

If you’ve installed the Apple developer tools for OS X Lion, then you should already have a working installation of Perl.  But you might find a need for some additional modules.

  • Visit CPAN and search for the name of the required module, such as “Net::Telnet::Cisco”.  If you have an existing Perl script, it probably identifies the requires modules near the top of the script.
  • Review that module’s information on CPAN to identify any prerequisite modules which need to be installed first, such as “Net::Telnet”.
  • open a Terminal session
  • to confirm Perl is installed, use:  mac$ perl -v
  • mac$ sudo su 
  • Password: AdminPassword
  • mac# cpan
  • cpan[n]> install ModuleName
  • cpan[n]> q       # ends the CPAN session
  • mac# exit        # exits sudo and returns Terminal session normal user permissions
Additional notes:
  • If you don’t “sudo su” first, the final steps of the module install process will fail.
  • If this is first time you’ve used “cpan”, you’ll be prompted with configuration options.  “automatic” should work just fine.  It will locate the URLs for the CPAN Mirror sites , complete the auto configuration, and provide the cpan prompt.

PS: after evaluating XCODE vs Komodo Edit v7, I found XCODE to be adequate for editing Perl.  Normally I would not make a case for using an IDE to edit a Perl script, but I’ve recently been asked to refactor a collection of large systems management scripts.  In this situation, using an IDE to organize the files and provide source control is imperative.

  • syntax highlighting:  XCODE was able to perform syntax highlighting equivalent to Komodo Edit.
  • code completion: XCODE offers completion of some basics items.  Plus it offers completion for anything you’ve already typed elsewhere in the project. Komodo Edit has full completion for some methods, but on others it only offered a hovering text box suggesting some syntax that you might use.
  • source control:  Komodo Edit has a menu option to “back up” a file to another location.  XCODE treats the Perl files like any other project file, with full control of updates, comments, tracking, etc.
  • The full (paid) version of KOMODO is probably a nice tool if you spend most of your time with the languages it focuses on.  The free version may be useful if your learning one of the supported languages and don’t have other tools available; however, it doesn’t offer enough capabilities to justify it over XCODE or Eclipse if you already use one of those.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s