S
Suresh Govindachar
Hello,
Page 789 of Programming Perl says that the block or
routine used for sorting cannot be exited "with a loop
control operator". What does this mean?
Specifically, is the following OK or not-OK?
sub the_sorter
{
my $rv = 0;
for my $i(1..10)
{
# some code involving $a and $b
# an assignment to $rv
$rv and last; # exitting the loop inside a sort subroutine.
}
return $rv; # explicit return statement; not a loop-control operator
}
I suspect the preceding is indeed OK; please give an
example of exitting a "block or routine with a loop control operator".
Thanks,
--Suresh
Page 789 of Programming Perl says that the block or
routine used for sorting cannot be exited "with a loop
control operator". What does this mean?
Specifically, is the following OK or not-OK?
sub the_sorter
{
my $rv = 0;
for my $i(1..10)
{
# some code involving $a and $b
# an assignment to $rv
$rv and last; # exitting the loop inside a sort subroutine.
}
return $rv; # explicit return statement; not a loop-control operator
}
I suspect the preceding is indeed OK; please give an
example of exitting a "block or routine with a loop control operator".
Thanks,
--Suresh