in reply to newbie questions on array access and control loops
No insult, but I'm having trouble understanding your question. Are you trying to say that you have a file that you're processing line-by-line, and you want to "remember" whether you've seen a particular marker line? (In other words, do something if you've seen the marker line, and another thing if you haven't. I'm kinda guessing that's why you're using two different arrays.) If so, the range operator (..) is perfect for this:
You can find more information on the range operator here or here.while (<FILE>) { my $seen_marker = 1 .. /PAGE: 2/; if ($seen_marker) { # one thing } else { # another thing } }
HTH
|
|---|