Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Unix shell versus Perl

by dwm042 (Priest)
on Feb 19, 2008 at 19:03 UTC ( #668870=note: print w/ replies, xml ) Need Help??


in reply to Unix shell versus Perl

Early in my career, one of my first professional jobs was in a hard core korn shell/C shop. Easy stuff was done in korn. Anything requiring more than a page we wrote in C. Now, as I read this post, I think you're trying to focus on negative reasons to not use shell. Some of them seem forced to me (slow? What ksh programmer worth their salt uses, oh, an external call to sed or awk for what a read loop would do?).

I think it misses the point entirely. The main reasons to switch are power and productivity. Rather than beating people out of skills they might be expert at, show them how much more can be done with a reasonably sized Perl script. If you tell them they'll get the same jobs done in a fraction of the time, a fraction of the space, and the result will do more than they could with shell, then you have a potent argument.

Tell them they can write daemons in Perl. Tell them they can write dynamic web pages. Tell them they can set up small Internet servers. Tell them their scripts don't have to use email anymore for notification, they can open a port and send the data directly into their alerts system.

Or, if they come from a hard core korn shell/C environment, tell them they can do in Perl most of what used to require C. And since Perl is an interpreter, you develop code faster.


Comment on Re: Unix shell versus Perl
Re^2: Unix shell versus Perl
by peterdragon (Beadle) on Feb 19, 2008 at 23:30 UTC
    One job I had many years ago was writing a standard installer for a Unix app written in C. I used shell. But it had to run on AIX, ICL Unix, DEC Unix, Sys V SCO OpenUnix and BSD. Very little standardisation across shells on those platforms, nightmare to work around the quirks of different machines.

    Let me give another example of shell suckiness. Write a script to run FTP, check the output and if it fails do some rollback action. Perl, easy (Net::FTP). Shell, you run, grep and pray. Again, different platforms, different ftp command line syntax... Linux, Solaris, argh.

    Regards, Peter
    http://perl.dragonstaff.co.uk

      My experiences are different. I once rewrote from scratch an installer/upgrader for the product the company I worked for produced. The result, a 2.5k shell/awk program, using isql (Sybase command line tool) to do its interaction with the database. Initially developed on Solaris, but I knew it had to run on HP-UX and Windows NT as well. The porting took less than 30 minutes - I was using an option to grep HP-UX didn't know about, and Windows NT (which had a Unix toolkit installed) didn't know about /tmp.

      Later, I've used shell scripts initially developped on Linux without much problems under Windows/cygwin.

      Of course, you may say, Windows doesn't come with a Unix toolkit. You are right of course. But Windows doesn't come with Perl either, so whether you want to use Perl or shell to do your cross-platform scripting, you will have to install something.

      Why I didn't write the installer I mentioned in the first paragraph in Perl, you may ask. Well, at that time, Solaris didn't come with perl, so we couldn't assume perl was available. And I hadn't convinced the company I worked for that we should just bundle perl with our product. Yet. A year later, I had to write a different installer. By then, we did bundle perl with our product, and that one was written in Perl. By the time, we had dropped Windows as a platform so I don't know whether it would have worked on Windows.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://668870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-21 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls