Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!milo.mcs.anl.gov!midway!ellis.uchicago.edu!goer From: goer@ellis.uchicago.edu (Richard L. Goerwitz) Newsgroups: comp.lang.perl Subject: Re: perl compared to other Unix tools Message-ID: <1990Dec9.193205.5794@midway.uchicago.edu> Date: 9 Dec 90 19:32:05 GMT References: <1990Dec8.020706.28417@midway.uchicago.edu> <1990Dec09.052353.18018@chinet.chi.il.us> Sender: news@midway.uchicago.edu (News Administrator) Organization: University of Chicago Lines: 60 In article <1990Dec09.052353.18018@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) writes: > >Ok, sticking to the text handling features relating to the original question, >there may be other languages that would easily sort text by keys. But there >was also a mention of needing to manipulate it when a match occured. >Does anything else let you do those wonderful combination test, assign >and regexp extract like perl's: > >if (($got1,$got2,$got3) =($var =~ /(pattern1) (pattern2) (pattern3))) { > ... do whatever you want with $got1 etc. >} > >Or handle multi-line regexps like this piece from the example I posted >where it takes everything between a SUMMARY: line and STATUS: line >in one item and inserts it before the STATUS: in an update which lacks >the SUMMARY information? > >local ($*) = 1 ; # multi-line match needed >[...] ># snarf summary from old - note multi-line >if (($status) = $oitems{$oldid} =~ /(^SUMMARY:\n[^\0]*)^STATUS:/) { ># and insert into new >substr($nitems{$newid},index($nitems{$newid},"STATUS:\n"),0) = $status ; >} Again, it's not the string processing tools that make perl unique. It's the combination of tools and their particularly facile integration with the operating system that make perl unique. The regexp stuff you mention above is peanuts in languages like Snobol and Icon. In fact, regular expressions are felt, by Snobol and Icon programmers, to be insufficiently powerful for the sorts of things they do. Multi-line matches, non-regular languages, and other bits of trickery are the bread and butter of languages like Snobol and Icon. Note, though, that to do the things you mention above takes more space in at least Icon than perl - that is, if you restrict yourself to pat- terns that can be recognized using a deterministic finite state auto- maton. And for this restricted pattern-type, perl will probably run faster than Icon and Snobol (but what about Spitbol?). There are ups and downs to everything. I guess what I'm saying is that statements like the one I'm responding to above indicate that people really don't know about the grand old tradition of nonnumeric processing we see in systems like COMIT (ee gads), SNOBOL4, Spitbol, Icon, and offshoots like awk, nawk, and now languages which incorporate elements from these, like perl. I really never wanted to get into any argument here. I've never taken a course from a computer science departement in my life (I'm currently finishing up a PhD in Near Eastern Languages), and I feel out of my element. When people started taking me to task for saying that perl wasn't uniquely suited to sorting, hashing, and matching tasks, I guess I felt I had to say something. As I've said before, perl is neat tool, and if it had no usefulness, I would not be here. Keep on perling! -Richard (goer@sophist.uchicago.edu)