PDA

View Full Version : Perl - foreach



SJP
12-20-2003, 06:09 PM
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

SJP
12-21-2003, 10:12 AM
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