From: krisk@ux1.cso.uiuc.edu (Kris Klindworth)
Subject: Re: AWK or PERL: which is better?
Organization: University of Illinois at Urbana
Date: Tue, 29 Sep 1992 22:47:45 GMT

bruce@head-cfa.harvard.edu (Bruce Sams) writes:


>After some experimenting with awk (I have just downloaded perl from MIT)
>I am now at the cross roads: which one of these languages is "better", and
>which should I learn?  Is there a general rule about the simplicity,
>applicability, and speed of these two editors? Are ther strong opinions
>(either way) about awk or perl?  I am a new system manager and would
>like to tell my users one language which they can learn and use in almost
>all situations, and with the least startup time for learning.  In this
>respect awk seems very good, but maybe perl is better.


A few pro's and con's.

Awk:
	+ great for most text manipulation.
		I maintained our databases for a year when
		 we were between DBMS's using awk 
		 (this was before I new about Perl ;-)
	+ great tutorial book.
		(The AWK Programming Language by Aho, Kernighan, & Weinberger)
	+ easier to learn
	+ small, elegant language
	+ Mnemonic variable names which are easer for the casual
	  user to remember.
	  Examples:
		awk		perl	 meaning
		--------	------   ------------------------------------	
                NR              $.       Number of current input record
                FILENAME        $ARGV    Name of current input file
                RS              $/       Record Separator (for input records)
                ORS             $\       Output Record Separator
		
	- some versions have low arbitrary limits on the number of fields
	  it will parse and on the length of the input line.
	- must use a shell script to turn programs into unix commands

Perl:
	+ More powerful for manipulating text than awk.
	+ Has report generating features not built into awk.
	+ No arbitrary limits on line lengths or number of fields.
	+ Programs can be made executable like a shell script.
	+ Can be used for manipulating processes.
	+ Can fork new processes.
	+ Good support for interprocess communication.
	+ Great language for developing systems administration tools.
	- More difficult to learn and remember. Part of this is because
	  of all of the things perl can do in addition to manupulating
	  text.
	- No tutorial book suitable for Unix beginners, though
	  there is one being written.
	


In MOST cases I recommend awk to my users. They
learn to use it more quickly and retain that knowledge longer.  

Because I push data around for a living and have systems adminstration
work to do, I use Perl.  Where awk was designed mainly for generating
reports, perl was designed for all of the things systems administrators
need to do.  It can do anything awk can plus it does much that awk
can't do without calling other programs.  I use it almost daily
so I don't have a chance to forget the things I know and over time
I continue to learn how to use other features.



------------------------------------------------------------------------------
Kris Klindworth                    Internet: krisk@ux1.cso.uiuc.edu
Database Programmer/Analyst        Phone   : (217)244-7120
Illinois State Water Survey        US Mail : 2204 Griffith Dr
                                             Champaign, IL 61820
Newsgroups: comp.unix.questions,news.newusers.questions