next does not a loop make.
The error is pretty clear, I think. You don't have a loop, so you can't next. You need to create a loop, like below. Note that you didn't have any checking for odd conditions, such as $key and $self->{FIRSTKEY} never matching. Thus, you could have run off the end of @KEYS (which I assume you define elsewhere), creating an infinite loop and lots of warnings about undefined values.
sub NEXTKEY { my $self = shift; #my $lastkey = shift; # Do you need this? If not, don't bother shi +fting it until($self->{FIRSTKEY} eq $KEYS[$self->{INDEX}]) { ++$self->{INDEX}; last if $self->{INDEX} >= $#KEYS; # Quit if we run out of @KEYS } return($KEYS[$self->{INDEX}]); }
PS, you should probably wrap any code you post here in <CODE> </CODE> tags, so that any special characters, like <, >, [, and ] are properly escaped.
bbfu
Black flowers blossum
Fearless on my breath
In reply to (bbfu) Re: Can't "next" outside a loop block
by bbfu
in thread Can't "next" outside a loop block
by hbradshaw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |