Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!stef From: stef@zweig.exodus (Stephane Payrard) Newsgroups: comp.lang.perl Subject: perl compared to other Unix tools (was: a pointer for a perl compare script) Message-ID: Date: 7 Dec 90 21:04:10 GMT References: <12020@milton.u.washington.edu> <1990Dec04.230436.8432@chinet.chi.il.us> <1990Dec5.060300.21410@midway.uchicago.edu> <275E7B47.2EB9@tct.uucp> Sender: news@exodus.Eng.Sun.COM Reply-To: stef@eng.sun.com Organization: Sun Microsystems -- Mountain View Lines: 111 In-reply-to: chip@tct.uucp's message of 6 Dec 90 17:09:27 GMT > > From: chip@tct.uucp (Chip Salzenberg) > Newsgroups: comp.lang.perl > Subject: Re: Needed: a pointer for a perl compare script (long, sorry..) > Date: 6 Dec 90 17:09:27 GMT > Organization: Teltronics/TCT, Sarasota, FL > > According to goer@quads.uchicago.edu (Richard L. Goerwitz): > >Perl is not the only language around that is optimized for file, > >string, and symbol processing, which has associative arrays, and handles > >sorting and printing elegantly. If you can't think of any examples off- > >hand then mail me, and I'll be glad to provide you with a few. > > Come now, Richard. If you criticize in public, you must put up your > facts in public. Name these other languages. Oh yes, and please > include availability and cost information. > -- > Chip Salzenberg at Teltronics/TCT , > "I'm really sorry I feel this need to insult some people..." > -- John F. Haugh II (He thinks HE'S sorry?) I agree very much with Chip; if you know a better tool than perl, you should not let us in the dark. I am curious to know which tools are better to do the dirty tasks which involve string pattern-matching, some non trivial processing and some system calls with as main input a big file (say .5 to .1 MB) in a reasonable amount of time (say less than 1 minute) Surely not nawk. I am sure that nawk, sed ,ex (or any tool (orcombination of) which come with a "standard Unix distribution) would never allow to write the kind of programs I have written with perl: -it has not the functionalities offered by perl -it has not the performance of perl -it offers no direct access to the OS (system-calls) I don't pretend that perl is an answer to every problem, but it is certainly the best I know of for the class of program I defined in the first paragraph of this mail. The idea of combining basic tools using pipes, backquotes or whatever, is a UNIX myth propagated by most of the UNIX books. Each time I have tried to do a non trivial task this way, it happened to almost be impossible for a simple minded guy for me ;-). Each command/shell has a a different set of metacharacters; this makes the combination of this atomic tools very tricky ("How many backote should I put before this character?"). Moreover, none of these tools come with a debugger. Anyway, if they did, it would not be very useful if your script is a complicated combination of those tools. I am sure when the perl book will come-up, it will be more easy to learn perl that to acquire the UNIX expertise necessary to use and combines the UNIX atomic tools or shells (grep, sed, wc, awk. sh, csh, expr...). I am confident that, someday, someone will come with a program which will allow to use perl as an extensible interactive shell; this will relegate sh and csh in the rank of historically interesting tools. In the mean time you need the UNIX expertise because the perl documentation constantly refers to the UNIX one. An extreme example of what can be done with perl: I have written a 600 line program in perl which deals with a PostScript file generated by FrameMaker; it allows to preview and interactively browse the corresponding document (using NeWS/TNT); it extracts information to build menus; one of the menus allows me to go directly to any chapter of the documentation, keyboard accelerator allow to go from the current page to the next/previous. This program is able to browse a .5MB file, to generate a data file (used for subsequent runs) and pop-up the browser window in about 30 seconds using a (Sun 4/110) and assuming the TNT toolkit already loaded. Subsequents run pop-up the window in 5-6 seconds. Dont ask for this program: it used a not yet released version of TNT and make many assumptions about the browsed file. I am quite sure Larry has never intended perl to be used to write simple windowd tools, but with perl/TNT, it fit the bill. It is quite exciting to use NeWS with perl because NeWS is an interpretor as well. So perl can generate "in the fly" the NeWS code which deals with the windowed part of the tool. I prefer not to imagine a program such as the one I described written with whatever X toolkit and Display PostScript. fooey. In fact, perl is so powerful that I am very much tempted to write stuff I should write in C. And I will write more in perl, if Larry come up some day with an equivalent of the C structs, because pack() and unpack() is an horrible kludge . I don't know very much how Larry could fit syntactically and semantically such an extension to the language. stef -- Stephane Payrard -- stef@eng.sun.com -- (415) 336 3726 SMI 2550 Garcia Avenue M/S 10-09 Mountain View CA 94043