Adam Sampson wrote: > > On Sat, Jul 03, 1999 at 12:51:19AM -0400, Brian Keefer wrote: > > So, can you see the simple, elegant change here? > > > > for(<>){split;$n='>';$w{$n}.=" $_[0]";while(@_){$w{$_[0]}.=$".($#_?$_[1]:0); > > shift@_}while($n){print"$n ";split' ',$w{$n};$n=$_[rand@_]}print$/} > > [the change was swapping "while" at the start for "for"] > > Grrr, that's annoying. Again, you can tell I'm really a C > programmer---for(x;y;z) is too deeply ingrained into my cortex to allow me > to do for(x). > > Plus perlvar(1) says: > > $_ [...] The default place to put an input record when a > <FH> operation's result is tested by itself as > the sole criterion of a while test. Note that > outside of a while test, this will not happen. > ^^^^^^^^^^^^^^^^^^^^ > > So I'd kind of assumed that a "for" test rather than a "while" test would > mean it wouldn't work. :) > > -- > > Adam Sampson > azz@gnu.org a for without the (;;) actually means foreach. foreach $foo (@bar) iterates throuch @bar, copying (by reference?) each element into $foo. An omitted $foo means to use $_, a common theme with Perl. It should work (unlike everything else I've posted). ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe