Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!apple!oliveb!orc!mipos3!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Done already (was Re: referencing scalars apart from subroutine calls) Message-ID: <1990Mar7.055852.1192@iwarp.intel.com> Date: 7 Mar 90 05:58:52 GMT References: <1232@frankland-river.aaii.oz.au> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 42 In-Reply-To: pem@frankland-river.aaii.oz.au (Paul E. Maisano) 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?). | 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? [inspired by a recent posting:] $_="kheauroes ,rJttParn lhc e";srand(1); while($a=length){$a=rand($a);print(substr($_,$a,1));substr($_,$a,1)="";} -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/