in reply to Script fails to insert text and appends it towards the end of file.

It's kinda hard to tell where this code may be going, but it smells like there should be a database involved. If this sort of random access to lines continues to be required beyond an initialisation phase then a database is likely to perform better with less messing around and less effort than most other techniques.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
  • Comment on Re: Script fails to insert text and appends it towards the end of file.

Replies are listed 'Best First'.
Re^2: Script fails to insert text and appends it towards the end of file.
by always_coys (Novice) on Nov 22, 2020 at 15:14 UTC
    Hi GrandFather, there is indeed a database involved. I am using Perl to run multiple instances of a finite element software. So, it requires the input files to be updated for every run, using values from the database.

      In that case wouldn't it be more efficient to add a table or tables to the database rather than work with external temporary files?

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

        In that case wouldn't it be more efficient to add a table or tables to the database...

        Or even dynamically create a temporary table or tables from within the code.