2010/03/22

The Labs.Com Admin Lab Perl Lab
Last update 2001/02/22

The Labs - Design & Functionality For The Net

Perl, The Joy of Programming

Perl is surely the most powerful language for the UNIX platform to handle system-adminstration tasks. I nearly write everything in Perl nowadays, even graphic applications, not to mentioned 95% of all my CGIs (exceptions are heavy used CGIs, ie. web-counter, or webchat).
  1. Introduction
  2. Online Documentation
  3. Comprehensive Perl Archive Network (CPAN)
  4. Perl & HTML
  5. Perl Examples
  6. Misc Perl Prgs
  7. Perl Compiler
  8. Perl
  9. Inline
Perl Lab
1. Introduction
Perl is certainly the best script-language I have encountered, and use it for all purposed. I only use to write C for resource-sensitive applications, I always try to find a way to use Perl.

Perl.Com
The main entry-point
use Perl;
Perl News service
CPAN.Org
Comprehensive Perl Archive Network
PerlTK
TK modules

Perl Lab
2. Online Documentation

Perl-Manual 5.005_02
Comprehensive Perl-Manual
Search Manual:
Enter 'faq' to read the Perl-FAQs.

Perl Lab
3. Comprehensive Perl Archive Network (CPAN)

There you find all the modules you likely will use to write your applications:
CPAN.Org
Original site
Nearest CPAN
Nearest copy of cpan
Search CPAN:

Install Modules

 

 perl -MCPAN -e 'install Time::HiRes' 

as example install the HiRes package.

Perl Lab
4. Perl & HTML

Using Perl within HTML isn't really support officially, but there are some more or less consistent approaches worthwhile to consider:
ModPerl
The basis . . .
PowerPerl
Inline perl using <script language="PerlScript"> tags
Embperl: Embed Perl in HTML
Embedded perl within HTML using [- and -] as tags
Mason
Very promising embedded perl <% ... %>
ePerl
Alike package, uses <? and !> as tags
ProgrammerHTML
Handler & Pre-processor
InlinePerlPages
Lightweight inline perl

Perl Lab
5. Perl Examples

Best is learning from the experts:
The Perl Journal: Programs
Back issues archived by issue & topic

Perl Lab
6. Misc Perl Prgs

Here some of our perl-stuff we did:
SystemViuw
Small PerlTK script show cpu/memory and disk-space
NetViuw
Small PerlTK script shows netstat
PerlFlash
Writing flash .swf via perl
DNSTool
Making life easier with bind-4.x and bind-8.x
and more programs, as we use perl almost for everything . . .

Perl Lab
7. Perl Compiler

The long expected is finally here, the perl compiler.

test.pl:

 #!/usr/local/bin/perl 
 print "Hi there!\n"; 

Byte Code

 First level of compiling (as the interpreter usually does) is the byte-code:

 perlcc -b test.pl 

and you get test.plc, which is machine-independent, executed by perl test.plc.

Compiled

 To compile it truly into a binary (via C-source and cc)

 perlcc test.pl 

and you get test, which is now machine-dependent.

Reversing Byte Code

 You can also translate byte-code back to source (great feature!):

 perlcc -MO=Deparse test.pl 

which creates byte-code and gives out the source-code; great feature to make source-code readable again.

Perl Lab
8. Perl::Inline

The module Inline provides a nifty interface (API) to other compiled or interpreted languages.

Inline::C

 The Inline::C allows to include C functions within the perl-source. Inline::C extracts the C-source and compiles the code into binary and is then called with appropriate arguments.

Advantage: fast and easy integration of performance sensitive C/C++ code.
Disadvantage: code is compiled first (once or when code changes) and binary is cached, may compromise perl-portability.

Many Perl5 modules provide interface to existing C/C++ libraries, Inline::C will provide a very fast and handy implementation approach; most useful for prototyping.

Example:

 use Inline C => <<'END_C'; 
  
 void greet() { 
    printf("Hello, world\n"); 
 } 
 END_C 
 greet; 

Download

 
Inline & Inline::C
Perl language interface
Inline::CPR
Running C as script (compiles itself if necessary)

It is to be expected more languages will be supported very soon (Jan 2001). We certainly will start to use Inline::C now extensively in our existing perl-programs (e.g. ProgrammerHTML and PicArt) which worked as interface to implement or interface another script- or compiled language.

                                                                                                                                   

Admin LabSymMount

Hipocrisy of the finest: "I agree that no single company can create all the hardware and software. Openness is central because it's the foundation of choice."
-- Steve Balmer (Microsoft) blaming Apple regarding iPhone, February 18, 2009

Last update 2001/02/22

All Rights Reserved - (C) 1997 - 2009 by The Labs.Com

Top of Page

The Labs.Com