uutraffic report (in perl)

J Greely jgreely at oz.cis.ohio-state.edu
Wed Nov 22 09:51:57 AEST 1989


In article <RICHARDT.89Nov21141554 at anableps.berkeley.edu>
 richardt at mica.Berkeley.EDU (Richard Threadgill) writes:
>In article <3273 at convex.UUCP> tchrist at convex.COM (Tom Christiansen) writes:
>> I have not written any awk or sed scripts since I 
>> perl, and certainly none of those horrendous sh scripts full of
>> multiple calls to sed and awk and tr and sort and cut and paste and
>> expand and grep and all their brethren.  

>To my mind this is the most powerful argument I heard *against* using
>perl.  Perl, like any other monolithic integrated system is wonderful
>for performing the tasks it was designed to encompass.  However, that
>also ties you to that monolithic system. 

I don't think Tom is advocating Perl as a complete replacement for the
Unix Way(TM), but as a complement to it.  There is a type of
programming task that's too clumsy or slow (or both) when written the
"old-fashioned" way, but not easily implemented in C (or just not
worth the time).  This is what Perl is for.  By some strange
coincidence, tasks of this type are extremely common in system
administration.  I suspect a straw poll of Perl users would turn up a
large number of sysadmins.

  Personally, when I want the first field of a text file quickly, I
still use awk, mostly because my fingers type "awk '{print $1}'"
faster than
	perl -ane 'print shift(@F),"\n";'
Had I ever bothered to make a short script 'pf':
	#!/usr/bin/perl
	$f = shift - 1;
	while (<>) {
		chop;
		@F=split(' ');
		print $F[$f],"\n";
	}
I'd just say "pf 1".  Of course, if I were writing it, I'd add a
switch to allow arbitrary regexps as field delimiters, and meaningful
error checking, but I digress.

>The whole point of having filters is that with a filter you can
>massage the input in just about any fashion you like.  Need a
>different filter? Spend the few minutes it takes to write one.

Unfortunately for your argument, I write filters in Perl.  Lots of
them.  Sometimes I chain them together, sometimes I just turn them
into a simgle program.  By the way, what's your stand on awk?  It's
more than just a filter; hell, it has FOR LOOPS.  It can do things
TOTALLY UNCONNECTED with massaging input.  Is it an evil repressive
tool?

>Maybe perl has the capabilities for all the filters you need now - if
>so, great.

You *do* know that Perl is a complete programming language, right?
Powerful enough that Larry Wall is supposedly writing the next version
of RN in it?  (I've never had the guts to ask him about this one,
myself; I'd really rather not know)

-=-
J Greely (jgreely at cis.ohio-state.edu; osu-cis!jgreely)



More information about the Alt.sources.d mailing list