Note the newline chars (\n), those are required to tell Tie::File that these will be new lines and therefore new records in the array.
Even though i'm fooling with @array[$i + n] here, there's no chance of running off the end of the array because the test will fail negative before any action is taken on non-existant elements beyond the last record in the array.
The suggestions about HTML::Parser and so forth are well recieved, but since all i'm doing here is *generating* the html snippets, i don't think the Parser is really the right thing.
### 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 my $i (0 .. $#threads) { if ($threads[$i] =~ $parent) { if ($threads[$i+1] eq "<ul type=\"disc\">") { # insert $link after the next element (after the <ul>) $threads[$i+1] .= "\n$link"; } else { # insert three new lines/records after the parent $threads[$i] .= "\n<ul type=\"disc\">\n$link\n</ul>\n" +; } last; } } } untie @threads;
Anyhow, thanks again for everyone's help! I hope this thread is useful to someone, someday.
Cheers!
914
In reply to Re: Conditonal insert into Array? (Tie::File)
by u914
in thread Conditonal insert into Array? (Tie::File)
by u914
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |