Helpful Information
 
 
Category: CGI Scripts / Perl
Perl - foreach

Is it possible to tell where the current pointer is at in a foreach loop so you can do another foreach from that point? Or in other words a foreach loop inside a foreach loop where the inner loop picks up from where the outer loop left off?

foreach my $p (@lines) {
.
.
foreach my $q (the next line $p would have gotten) {
.
.
}
}

thanks, SJP

Well I knew I'd find the answer in the Perl bible (Programming Perl 3rd Edition) I just didn't know where to look. The answer to my question - no. The only way to make do is by using ugly for loops with array indices.

SJP










privacy (GDPR)