naturalsciences has asked for the wisdom of the Perl Monks concerning the following question:
while (my $in = <IN>){ foreach (@ref){ if ($_=~ m/$in/){ print OUT "$_"; }}}
What if I would like to print out not $_ but the next iteration $_+ so to say. It has became a general problem to me. I regularily want to test an array element for a condition and then according to this retrieve another array element some steps "upstream". (Sorry about my language but I hope these expressions are able to carry my meaning)
Using loop control commands like next or redo seems kind of too brutal for this kind of work, I would like to hear your what methods do you suggest - and if possible a sample using the case above -- only instead of printing out $_ to print out $_ next value.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getting values for next array iteration when matching current
by Anonymous Monk on Mar 20, 2011 at 08:50 UTC | |
by naturalsciences (Beadle) on Mar 20, 2011 at 08:58 UTC | |
Re: Getting values for next array iteration when matching current
by wind (Priest) on Mar 20, 2011 at 15:50 UTC | |
Re: Getting values for next array iteration when matching current
by CountZero (Bishop) on Mar 20, 2011 at 19:38 UTC | |
Re: Getting values for next array iteration when matching current
by Marshall (Canon) on Mar 21, 2011 at 03:22 UTC | |
Re: Getting values for next array iteration when matching current
by choroba (Cardinal) on Mar 21, 2011 at 20:38 UTC |
Back to
Seekers of Perl Wisdom