Path: utzoo!utgpu!jarvis.csri.toronto.edu!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: Done already (was Re: referencing scalars apart from subroutine calls) Message-ID: <7316@jpl-devvax.JPL.NASA.GOV> Date: 7 Mar 90 18:44:04 GMT References: <1232@frankland-river.aaii.oz.au> <1990Mar7.055852.1192@iwarp.intel.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 48 In article <1990Mar7.055852.1192@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: : In article <1232@frankland-river.aaii.oz.au>, pem@frankland-river (Paul E. Maisano) writes: : | Hey, I just thought of one way: ;-) : | : | grep( do { : | ... # refer to array element as $_ : | ... : | }, : | $array[EXPR] : | ); : : Arrggh! grep() taken to the extreme!!! This is better supported as: : : for ($array[EXPR]) { : ... : ... : ... : } : : Same results exactly. If you assign into $_, the corresponding array : element changes (right, Larry?). Sorry, no. Only if you put the whole array in. The above gets translated internally to @_GEN_0 = ($array[EXPR]); for (@_GEN_0) { : | Now if I could only name the variable something other than $_ ... : : Presto magico: : : for $something_other_than_dollar ($array[EXPR]) { : ... : ... : ... : } : : How's *that* for fast implementation? Fast but still buggy. :-) But I'll admit it's real close to what he wants. : $_="kheauroes ,rJttParn lhc e";srand(1); : while($a=length){$a=rand($a);print(substr($_,$a,1));substr($_,$a,1)="";} Also non-portable to non-31-bit rand() machines. Larry