nv-l
[Top] [All Lists]

Re: Perl vs shell scripts

To: nv-l@lists.tivoli.com
Subject: Re: Perl vs shell scripts
From: Chris Cowan <chris.cowan@2ND-WAVE.COM>
Date: Tue, 16 Mar 1999 11:19:28 -0800
Organization: 2nd Wave
Reply-to: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
Sender: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
"MENEZES, ALAIN" wrote:
>
> I'd like to know whether Perl programming is better than shell scripts
> (speed ? efficiency ? easyness ?)
> And where I could get the package. .. Freeware ?

All of the above.    As far as getting the packages, every pointer
you'll ever need is at www.perl.com.
I have a bunch of web sites like Activestate, Bull's (AIX freeware
site), the Sun (smc.vnet.net) site, etc...
I doesn't take much time to go grab this stuff.   (And Tivoli ships with
perl4 on all Managed Nodes!)  Actually, it doesn't take much space
either.

Here are some of my reasons:

Portability - even though they share a common ancestory, bash, ksh, and
the bourne shell have lots of little syntactical differences.
(I'm not going to even discuss csh, which should have gotten the knife
long ago!)  Within Tivoli, I find myself having to restrict myself to
bourne syntax to make sure I'm always "safe." Actually the POSIX shell
is ideal, but you have to know where to get the docs ;)   There's also a
big problem with dependencies on external utilities like awk, sed, etc.
when used in conjunction with shell scripts.    Since perl has all of
this functionality integrated it makes for less headaches.   The biggest
problem you have with perl is worrying about Ver 4 vs 5.   And, it's not
that difficult.

Speed - If you use perl properly, you should see significant differences
in speed.   The problem is that you want to write code that uses modules
and makes systems calls directly, rather than just using the back
ticks.   Never fork a process unless you need to.   For example, I
constantly see people writing code that will do a `nslookup` rather than
use gethostbyname().

Easyness - Perl has it hands down.   After you've used perl in debug
mode, I can't see how anyone would want to go back.   (Of course, I'm
amazed at the number of people that forget about this!)


There of course a whole bunch of other reasons I prefer perl:
- Encourages writing of more modular and reusable code
- Actually has a concept of data types and structures (yes, I know some
of the shells have arrays!)
- Things like taint or suid protection, which you just don't find with
the shells (unless you're crazy!)
- Functionality, regexps, etc.

I could go on, but should probably stop.

Attachment: chris.cowan.vcf
Description: Card for Chris Cowan

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

<Prev in Thread] Current Thread [Next in Thread>

Archive operated by Skills 1st Ltd

See also: The NetView Web