[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shell scripts.



> 
> call me crazy, but after messing around with shell programming for a while, i
> discovered perl.  i'm no major system programmer or admin or anything, but
> why on earth would someone ever want to use some shell programming language
> over perl?  especially since perl can run on almost any platform, so when
> whatever shell you are programming for fades away or when you switch from
> one platform to another, your perl scripts will live on.

Answering your last questiions first,
yes perl runs on most every system, but so does the GNU bash shell.
I tired recompiling my C-programs, so I rewrote my simple ones in
shell scripts, which I run on both Linux and SunOS/Solaris.
As for fading away, the original sh shell has been around for how many 
decades? (at least 2 decades)
Still, perl is often already on other systems without going through 
a package install.

You are unlikely to run perl as your login shell.
One writes some one-liner shell programs for inclusion in .bashrc.
Since one already works with zher login shell, eg, bash,
one feels more comfortable programming it.  That argument fails when
you realize the csh shell was created for those used to C programming,
yet csh works poorly for shell programming.

Perhaps most importantly, perl does an enormous number of unix-like things
in an un-unix like way: it puts all the tools in one tool called perl.
One can more easily learn just the bash shell, or awk, or sed,
then, in the unix way, connect them with pipes.
Unfortunately, all these programs do not extend to all perl can do.

Of course, for big programs one should use perl.
I read a rule somewhere: "If the program is the size of a Makefile, 
write the program in a shell; for larger programs, write it in perl."
Indeed, if one doesn't start a new shell, then a small shell script running
under the current shell runs more quickly than starting perl to run
a perl script. But who worries about small unsummed computer times these days?

If a person makes only the simplest of programs, zhe can spend less time
learning a shell than learning perl.
If a person writes at least a 20 line program once a week, 
then that person would better spend zher time learning perl
than learning the admitedly not-so-deep details of a bash shell.

In unix, we share a great deal in common: a shell, pipes, xterms.
>From there, we diverge to other tools that differ, depending
on our tasks but more depending upon our views: for example, get it done now,
or be able to get future tasks done.
As the flexible user seeks Debian over RedHat, 
the same user chooses programming over gui tools, and
the same future-oriented user might well choose Perl over Bash shell 
programming.



Reply to: