in reply to Re: Passing Array to seperate file
in thread Passing Array to seperate file

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

Replies are listed 'Best First'.
Re: Re: Re: Passing Array to seperate file
by davido (Cardinal) on Mar 01, 2004 at 16:29 UTC
    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?