Novell is now a part of Micro Focus

Perl May Be the Way to Go

Articles and Tips: tip

01 Jan 2003


Paraphrased from the DeveloperNet

NDK Documentation

The Practical Extraction and Report Language (Perl) was created by Larry Wall and was designed specifically to process text. It was originally founded on the UNIX platform, and later on it was ported onto many platforms. The porting effort required for moving Perl scripts between different platforms is very minimal.

Perl is categorized as an open-source language since the sources are freely available to the programming public.This means that the Perl source is available to anyone who wants to access it. You can download the latest version of Perl from http://www.perl.com/CPAN-local/README.html

The team that ported Perl to NetWare took care to maintain standard Perl functionality, so programmers can base their Perl for NetWare development on industry-standard Perl reference sources.

Perl offers two main advantages on a NetWare system: CGI (Common Gateway Interface) Scripting and System Administration. CGI scripting is the most common way for a Web server to interact with users. You can use CGI scripting to increase the sophistication and functionality of your Web pages. Since Perl is such a powerful text processor, it has proved to be a valuable system administration tool on NetWare systems. Procedures that require manual interaction in NWAdmin and ConsoleOne can be automated using Perl.

NetWare offers three types of Perl extensions: http://developer.novell.com/ndk/perl5.htm

In addition, Perl for NetWare offers extensive database support via ODBC drivers specifically for NetWare.

The following sample code uses a database-independent interface (DBI) to access a database. The data source name (DSN) demo used in this sample is considered to be existing. This sample opens a connection to the specified DSN and performs basic operations on entries in the database.

use DBI; 
    
$absdsname= "dbi:ODBC:demo"; 
$user = "admin"; 
$passwd = "novell"; 
    
my $dbh = DBI->connect($absdsname,     $user, $passwd); 
    
if (defined $dbh)
{
    # Name of the table to be created 
    $TableName = "TestTable"; 
    
    # Create the table 
    $Query = "CREATE TABLE $TableName 
        (EMPID Integer, NAME CHAR(30)) "; 
    $dbh->do($Query);
    
    # Insert a record into the table 
    $Query = "INSERT INTO " . $TableName .
        " (EMPID, NAME) VALUES(1,
        'FirstName')"; 
    
    $dbh->do($Query); 
    
    # Read data from the table 
    $statement = "SELECT * FROM
        $TableName"; 
    
    # Preparing the script for execution
        and executing 
    $sth = $dbh->prepare($statement); 
    $rv = $sth->execute; 
    
    # Fetching the vale and displaying 
    while (@row_ary=$sth->fetchrow_array)
    { 
        print "(@row_ary)\n"; 
    } 
    
    # Remove the table 
    $Query = "DROP TABLE $TableName"; 
    
    $dbh->do($Query); 
    
    #Disconnecting from the database. 
    $dbh->disconnect; 
    
}
else
{ 
    print "Failed to connect\n"; 
}

* Originally published in Novell AppNotes


Disclaimer

The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates