Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: $# question Message-ID: <10520@jpl-devvax.JPL.NASA.GOV> Date: 24 Nov 90 20:31:25 GMT References: <109132@convex.convex.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 20 In article roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes: : Is there a spiffy Perl Way to handle the forward reference in each : iteration without the explicit variable-controlled loop? (or have I : happened upon the occasional exception that demands the for() : construct?) In general you do this with a backward reference in Perl: $prev = ''; for (@foo) { if ($_ eq $prev) { } ... $prev = $_; } Apart from that, there's no special way to do it. Sometimes you just hafta use a normal for(). That's what it's there for, therefore. Larry