| iMatix home page
| Libero home page | Libero documentation
| << | < | > | >>
Libero Libero
Version 2.32

 

The Perl Language

Overview

What Is Perl?
Perl is the mutant four-headed child of Awk, C, Sed, and the UNIX shells, plus just about every other language and feature that its creator, Larry Wall, could think of. I like this language.
Portability
Perl is fundamentally portable to UNIX boxes, and has also been ported to many other systems. Perl scripts are highly portable so long as you stay away from system-specific functions. This is pretty much as you would expect.
Pros and Cons
Pros: powerful and flexible; freely available; interpreted language. Cons: if you can't handle type-free languages where just about anything goes, return to Pascal. Perl is (IMHO) not a good place to start programming.
How To Get It
By Internet from ftp.uu.net and many other places.
Libero Supports
Libero supports Perl 5.x

Working With Perl

Example of code

Code fragments:

#################   MODULE FUNCTION NAME   #################

sub module_function_name
{
                                   #  Empty module needs no code
}

function private_function_name {
    $the_next_event = $ok_event;
    &\raise_exception ($error_event);
}

A fuller example.

Notes

If you have used Perl, you will appreciate the way it combines the best of all the UNIX text processing and programming tools. For example, you need only a few lines of Perl to read and parse a parameter file ('ini file') like this:

#============================================================
#  Parameters for program
#============================================================

[General]
    OutBox=outbox             # Subdirectory for sent faxes

[Connect]
    HostName=Badoit           # For Telnet
    UserName=autofax
    Password=autofax

[FaxDriver]
    PauseChar="~"             # Substitute for commas

[Station]
    Id=Station1               # Name of this local system

    open (INI, "autofax.ini") || die "Can't open autofax.ini: $!\n";
    while (<INI>) {
        chop;                           #   Remove trailing newline
        #   [SectionName] followed by optional comment
        if (/^\s*\[(\w+)\]\W*(#.*)?$/) {
            ($section = $1) =~ tr/A-Z/a-z/;
        }
        #   Keyword=Value followed by optional comment
        if (/^\W*(\w+)=("[^"*]"|\w+)\W*(#.*)?$/) {
            ($keyword = $1) =~ tr/A-Z/a-z/;
            ($value = $2) =~ s/"//g;    #   Remove any quotes
            $initial {$section, $keyword} = $value;
        }
    }
    close (INI);

Similar code in C is several pages. This applies to many aspects of Perl, so that a complex program may be only a few hundred lines long.

Perl is also fast, and works well with Libero. The 'require' statement lets me hide the generated code in a separate file.

The Perl development cycle is simple: when you change your dialog, re-run Libero. When you change the Perl program, re-run it. Hint: get your hands on the 'Programming Perl' Nutshell Handbook.


| << | < | > | >>
| Libero's Languages | The Awk Language | The C Language | The C++ Language | The COBOL Language | The GNU Borne-Again Shell Language | The Java Language | The Microsoft Setup Basic Language | The MS Visual Basic Language | The Perl Language | The Rexx Language | The UNIX C Shell Language | The UNIX Bourne Shell Language | The UNIX Korn Shell Language | The 80x86 Assembler Language
iMatix
Copyright © 1996-97 iMatix