in reply to Re: Re: Conditonal insert into Array? (Tie::File)
in thread Conditonal insert into Array? (Tie::File)
If i'm interpreting your code and comments correctly, you are expecting that
$threads[$i] .= "\n<ul type=\"disc\">\n$link\n</ul>\n";
will insert 3 (or 4?) new lines after line $i. Whilst this may work, at least some of the time, it is TWWTDI (the wrong way to do it:).
From the Tie::File pod:
Inserting records that contain the record separator string is not supported by this module. It will probably produce a reasonable result, but what this result will be may change in a future version. Use 'splice' to insert records or to replace one record with several.
You should replace that line with
splice @threads, $i, 0, '<ul type=\"disc\">', "$link",'</ul>';
Which says 'insert the list (second line above) at position $i, whilst deleting nothing (0)'.
See perlfunc:splice for more details.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Conditonal insert into Array? (Tie::File)
by u914 (Pilgrim) on May 28, 2003 at 22:18 UTC |