Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: a2p generates incorrect code Keywords: a2p awk perl bug for Message-ID: <8975@jpl-devvax.JPL.NASA.GOV> Date: 2 Aug 90 23:51:47 GMT References: <1990Aug2.090725.2029@tc.fluke.COM> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 24 In article <1990Aug2.090725.2029@tc.fluke.COM> dcd@tc.fluke.COM (David Dyck) writes: : The awk "for (i in list)" is translated into "foreach $i (@list)" : : To get it to run more like awk I changed the perl code to : read "for ($i=1; $i <= $#list; ++$i)" : : I don't mind perl not simulating the random order that : awk uses, but is there a better way to do this? After the next patch it will spit out foreach $i ($[ .. $#list) : PS. (I came upon this while trying to convert the 'Lisp interpreter in Awk' : that was posted to comp.lang.lisp and alt.sources into : 'Lisp in perl'. After correcting the bug, perl was only a : little slower that awk). : : AWK: real 0m5.03s user 0m4.73s sys 0m0.11s : PERL: real 0m5.10s user 0m4.78s sys 0m0.21s Hmm, not too bad for un-idiomatic Perl. I bet it could be made to run twice as fast with a little perlish polish. Larry