Using CPAN (Comprehensive Perl Archive Network)

Learn how to use CPAN.

About this task

To add a Perl module from CPAN, you must run the nzcpan command and then install your module by using the CPAN application commands. When you installed the Netezza analytics packages, setup CPAN for hosts and SPU and install a module to test.

Procedure

  1. From a command line, run nzcpan host.
    If you have never run the command before, accept the defaults that the command chooses.
    [nz@host]$ nzcpan host
  2. Issue the following command from the cpan prompt.
    install String::Util
    Wait for the command to complete.
  3. Run nzcpan spu from the command line.
    If you have never run the command before, accept the defaults that the command chooses.
    [nz@host]$ nzcpan spu
  4. Issue the following command from the cpan prompt.
    force install String::Util
    In this case, you must use force because the CPAN resources are shared (although the paths for Perl are different).
  5. When the installations are complete, exit nzcpan and create the following AE.
    #########################################################################
    package Unquote;
    use nzae::Ae;
    use strict;
    use String::Util ':all';
    use autodie;
    our @ISA = qw(nzae::Ae);
    my $ae = Unquote->new();
    $ae->run();
    sub _getFunctionResult(@)
    {
    my $self = shift;
    # BREAK APART OUR ROW OF INPUT.
    my $str = $_[0];
    return unquote($str);
    }
    1;
    #########################################################################
  6. Compile and register the program by using the following.
    commands:/nz/export/ae/utilities/bin/compile_ae --language perl --version 3
    --template deploy Unquote.pm
    /nz/export/ae/utilities/bin/register_ae --language perl --version 3 --template
    udf --exe Unquote.pm --sig "unquote(varchar(10000))" --return "varchar(10000)"
    --level 4
  7. Test the installation.
    [nz@host]$ nzsql
    Example:
    [nz@host]$ nzsql
    Welcome to nzsql, the IBM Netezza SQL interactive terminal.
    Type: \h for help with SQL commands
    ? for help on internal slash commands
    \g or terminate with semicolon to execute query
    \q to quit
    SYSTEM(ADMIN)=> select unquote('"hello"');
    UNQUOTE
    hello
    (1 row)