Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR/AA) Newsgroups: comp.lang.perl Subject: Re: Shortest Perl and Awk programs Message-ID: <1991Apr5.004600.17363@NCoast.ORG> Date: 5 Apr 91 00:46:00 GMT References: <9004@rsiatl.Dixie.Com> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR/AA) Followup-To: comp.lang.perl Organization: North Coast Public Access Un*x (ncoast) Lines: 29 As quoted from <9004@rsiatl.Dixie.Com> by eeh@Dixie.Com (Ed Howland): +--------------- | !0 | Is there anything shorter? Why does'nt just '1' (or any non-zero value) work? +--------------- It probably matches the line number, so a given positive number N would match only on line N. (??? I have never understood all of awk completely; the documentation for standard awk seems to leave a lot to be desired. The new awk and GNU awk may well be different there --- new awk has a book, at least.) +--------------- | Also, does this hold true to perl? (Sorry I don't know perl well enough to | to even guess.) What would be the shortest perl program to do this? +--------------- "perl -pe ''" is the shortest, but may not be fair because it uses command line arguments to "imply" a script. 'while(<>){print;}' is longer, as is 'print while$_=<>'. Note that because Perl is more general-purpose than awk, it doesn't do looping on input or printing by default (except with -p). ++Brandon -- Me: Brandon S. Allbery Ham: KB8JRR/AA on 2m, 220, 440, 1200 Internet: allbery@NCoast.ORG (QRT on HF until local problems fixed) America OnLine: KB8JRR // Delphi: ALLBERY AMPR: kb8jrr.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery KB8JRR @ WA8BXN.OH