in reply to Re: Passing array pointer through script input
in thread Passing array pointer through script input

OK, the whole story.
I am passing file paths in the loop from the main script through several levels of script calls. In the bottom I read files and process.
Sinse main script is also looped, I want to do something like to store files in array of arrays once and read from these arrays instead of reading from files which should be much faster.
  • Comment on Re^2: Passing array pointer through script input

Replies are listed 'Best First'.
Re^3: Passing array pointer through script input
by GrandFather (Saint) on Aug 20, 2008 at 22:49 UTC

    Sounds like premature optimization. If the work you are doing per file is significant then the minor overhead of reading a list from a small file is trivial.

    It may be worth using something like DBM::Deep to store the list of files to be processed however to make management of the list easier and perhaps faster.


    Perl reduces RSI - it saves typing
      The file has a special structure with addressing which allows a quick regection and that's why reading is a bottleneck not processing. Processing is much faster.
      I do not want to change this part and therefore I do not think I can use DBM::Deep.
      So actually the question is if it's possible to effectively pass arrays to called scripts. Join to a long string with /\n/ separator and then split inside...? Or how?

        You would be much better to turn myscript.pl into a module and call into it directly. There is likely to be at least as much overhead running myscript.pl in that fashion is there would be in passing your list through a file. Turning myscript.pl into a module avoids both costs and allows beter integration between the two pieces of code.


        Perl reduces RSI - it saves typing
        Maybe old-school piping via STDOUT/STDIN (see IPC::Open2) is something for you if you can write/retrieve the arrays line by line?