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

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
  • Comment on Re^5: Passing array pointer through script input

Replies are listed 'Best First'.
Re^6: Passing array pointer through script input
by vit (Friar) on Aug 20, 2008 at 23:30 UTC
    Yes, it's possible but I do not want to do redesigning.
    I think if I pass a long string as input stream and split it inside it should be OK because it's all done in RAM and should be much faster then reading files from disk.
    What do you think?

      I think the overhead of starting up a new instance of the Perl interpreter, opening and reading myscript.pl's source, parsing it and finally executing the compiled code is likely to be much more expensive than opening a small file and parsing it line by line to extract file names. Fiddling about with serializing an array, passing it on the command line then deserializing it on the other side is about as much work as changing your myscript.pl to a module.

      To turn myscript.pl into a module you need only add package MyScript; at the top, wrap the main code in a sub and add 1; at the end. With the main block as a sub the command line processing code turns into my (param list) = @_;. Where's the problem?


      Perl reduces RSI - it saves typing