Miko wrote: > I don't know if we're talking about the same thing, but I live using loops > that declare variables in the test, so please exegize me. Which of these > lines, if any, would cause a compiler error or warning? > > while my $cond = blah() { > ... > } > else { > print $cond; > } > > print "The condition is: $cond\n"; > > If none then you're seriously rocking my world.
Then I'm seriously rocking your world. In Perl 6 a lexical variable is scoped to the block in which it's declared. Since C<$cond> is declared in the block *containing* the C<while> and C<else>, it's scoped to that block. So you can use it inside the C<while>'s block, inside the C<else>'s block (assuming Larry allows such a construct), and in the following C<print> statement. Damian