Using IMu's Perl Library
The IMu Perl API source code bundle for version 2.0 (or higher) is required to develop an IMu-based application. This bundle contains all the modules that make up the IMu Perl API. Contact Axiell Support for access to the IMu API bundles
To build Perl applications the source code bundle must be extracted on the
server machine and the path to the source code specified in the
PERL5LIB environment variable or as an argument to the lib
module. For example, if the IMu API source code is installed in the directory /usr/local/lib/imu
the following lines would be added to the Perl
code:
use lib '/usr/local/lib/imu';use IMu;
Test Program
Compiling and running this very simple terminal based program is a good test of whether the development environment has been set up properly for using IMu:
#!/usr/bin/perl use strict; use warnings; use lib '/usr/local/lib/imu'; use IMu; printf("IMu version %s\n", $IMu::VERSION); exit(0);
The IMu.pm
file defines a class called IMu
. This class includes the
member VERSION
which contains the version of this IMu release.
Exceptions
Many of the methods in the IMu library objects throw an exception (die
in
Perl terminology) when an error occurs. For this reason, code that uses IMu
library objects should be surrounded with an eval
block.
The following code is a basic template for writing Perl programs that use the IMu library:
# ⋯ eval { # Create and use IMu objects # ... }; if ($@) { # Handle or report error # ... }
Most IMu exceptions throw an IMu::Exception
object. In many cases your code
can simply handle the $@
variable (as in this template). If more
information is required about the IMu::Exception
object thrown, see
Exceptions.
Note: Many of the examples that follow assume that code fragments have been surrounded with code structured in this way.