I'm using Tie::File to open a file, and insert some text after a particular tag. I need to be able to make some decisions though, and in order to do that I need to know what the *next* element in the array is, and act accordingly.
Here's the pseudo-code i'm trying to work out:
The issue here is that i can't figure out how to say "The element after the current one" or "The second element after the current one".### Update the main threads file tie @threads, 'Tie::File', $main_threads_file or syslog('err', "update +_threads couldn't open file: $main_threads_file"); if ($thread == $msg_id) { # put it right at the top, it's a new thread unshift @threads, $link; } else { for (@threads) { if (/$parent/) { if (##next element is "<ul>"##) { #insert $link after the next element (after the <ul>) } else { $_ .= "<ul>"; ## the next element after that .= $link ## the next element after *that* .= "</ul>" } last; } } } untie @threads;
In reply to Conditonal insert into Array? (Tie::File) by u914
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |