[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Shuffling (was Re: [FWP] Perl Card Games)



Ronald J Kimball wrote:
> On Thu, Aug 05, 1999 at 01:15:03PM -0400, Amir Karger wrote:
> > On Thu, Aug 05, 1999 at 04:16:52PM +0000, Bennett Todd wrote:
> > > So Fisher-Yates looks like
> > > 
> > >      for (my $i = @_; $i > 0; $i--) {
> > >           @_[$i, $_] = @_[$_, $i] for rand $i+1;
> > >      }
> > 
> > Is this use of "for" as a simple statement documented? Also, I'm not sure
> > it works for me.
> > 
> 
> That's not a statement, but a statement modifier, just like the statement
> modifier forms of if, unless, and while, except that statement modifier
> for/foreach was not added until perl5.005.

Actually, it was added in 5.004_05, but not, I suspect for this usage. You're
more likely to see it with a list:

  $\="\n";
  print foreach @ARGV;

-- 
	Peter Haworth	pmh@edison.ioppublishing.com
"I am returning this otherwise good typing paper to you because someone
has printed gibberish all over it and put your name at the top."
                --English Professor, Ohio University


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe