Path: utzoo!attcan!uunet!samsung!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!oz.cis.ohio-state.edu!jgreely From: jgreely@oz.cis.ohio-state.edu (J Greely) Newsgroups: alt.sources.d Subject: Re: uutraffic report (in perl) Message-ID: Date: 21 Nov 89 22:51:57 GMT References: <4025@mhres.mh.nl> <1194@radius.UUCP> <3273@convex.UUCP> Sender: news@tut.cis.ohio-state.edu Reply-To: J Greely Organization: Ohio State University Computer and Information Science Lines: 59 In-reply-to: richardt@mica.Berkeley.EDU's message of 21 Nov 89 22:15:54 GMT In article richardt@mica.Berkeley.EDU (Richard Threadgill) writes: >In article <3273@convex.UUCP> tchrist@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@cis.ohio-state.edu; osu-cis!jgreely)