in reply to Passing Array to seperate file

See perldoc -f open and perlopentut with respect to opening a pipe to another command or process. You could open a pipe to the other Perl script, and then print the contents of your array into that pipe for the other script to retrieve via STDIN.


Dave

Replies are listed 'Best First'.
Re: Re: Passing Array to seperate file
by scottness (Initiate) on Mar 01, 2004 at 16:22 UTC
    I have read over the perldoc -f open documentation. can you provide a simple code example of the process for an array in file1 called "@combined" and to be used in file2 called "switch.pl" Thanks
      That's why I suggested reading perlopentut. Here's an example.....

      # controlcript open WORKER, "| workerscript.pl" or die; print WORKER "$_\n" for @combined; close WORKER; # This is the worker script, entitled workerscript.pl my @combined; while ( <STDIN> ) { push @combined, $_; } chomp @combined;

      Or just slurp in the worker script...

      my @combined = <STDIN>; chomp @combined;

      Dave

        This code looks like it would work, but I want to have the initial script to finish completely before I call the second and I believe the code you have will pipe the information as it happens. Some background. What I have is my initial file pulling files from my server and adding to my array if it meets a certain criteria. I added the system(targetscript.pl, @arraytobepassed); after all files have been checked. I want to use that @arraytobepassed in my second file which parses the "filtered array" and does it's own processing. But I can't get it to work since I have my code set to read each line from a file instead of an array. Any help?