The Haiku/BeOS Tip Server
Tips and tricks for Haiku/BeOS users

Installing and using CPAN perl modules

Contributed by: Tom Spindler
This tip is valid for: Both BeOS and Haiku

[Editor’s note: If you’ve got perl for BeOS installed, you can extend its functionality by downloading and installing additional modules from the CPAN network. Because modules can be installed directly from perl, you don’t even need a browser open. This tip explains both how to use CPAN from within perl, and how to get, install, and use the BFS attribute module, which lets you create perl scripts that treat BeOS file system attributes as a database. The Tip Server generates most of its pages on the fly with the help of this module.]

So, you want to install a module on your lovely perl system? But, you say, you don’t want to have to plow through ftp or webpages? Never fear, CPAN is here.

First, make sure that you’re connected to the ‘net. Then, type

perl -MCPAN -e shell

You’ll see an awful lot of questions. Hit return to all of them until you see some questions relating to what continent you’re on, etc. Answer it, and then you’ll get a list of URLs you can use. You can enter multiple numbers on the line (e.g. “1 2 3 4”). After answering this, you’ll be dumped to the following prompt (or something similar):

cpan shell — CPAN exploration and modules installation (v1.48)

ReadLine support availible

cpan>

You can search to see what Be modules are availible; since I’m conveniently telling you here that all Be-related modules are of the form Be::Foo, you can tell it to search for only those:

cpan> i /Be::/

(lots of crap you can ignore, followed by something similar to this:)

Module id = Be::Attribute
    CPAN_USERID  TSPIN (Tom Spindler )
    CPAN_VERSION 0.01
    CPAN_FILE    T/TS/TSPIN/Be-Attribute-0.1.tar.gz
    INST_FILE    (not installed)

Aha! Be::Attribute sounds mildly interesting. You can install it by typing

cpan> install Be::Attribute

(more crap…)

  /bin/make install — OK

cpan>

Well. Now that we’ve got it, what do we do with it? Type ‘q’ at the prompt, and then at the bash prompt, type ‘perldoc Be::Attribute’:

cpan> q 
Lockfile removed.
$ perldoc Be::Attribute

/bin/sh: nroff: command not found
=head1 NAME

Be::Attribute - get and set MIME file attributes

=head1 SYNOPSIS

  use Be::Attribute;
  $node  = Be::Attribute::GetBNode("/my/file/here");

(and so on…)

You should be able to figure out what to do from here.

More things you can do with CPAN

perl -MCPAN -e shell will get you back to the cpan prompt. From there, you can type ‘h’ to see the commands availible, or use ‘i /foo/’ to search for modules that have the pattern ‘foo’ in their names, or ‘r’ to see if there are updated modules you can install.

One final note:

Ignore the ‘Please, install Net::FTP’ messages. Be’s perl doesn’t yet have socket support (as of 3 May 1999, at least) and it will not work.

Posted in Networking


(comments are closed).