![]() |
|
There's more than one way to do things | |
PerlMonks |
Re: How to pass array as a reference from one perl file to otherby John M. Dlugosz (Monsignor) |
on May 15, 2011 at 04:46 UTC ( #904912=note: print w/replies, xml ) | Need Help?? |
I would agree with the second reply, that in this example your test-2.pl should be loaded to become part of the same program, not run as a separate process. But maybe the example is easier than the real problem? If it's an existing program or a real mess and you can't alter it, you need some kind if Inter-Process Communication. But if you can't alter the existing program, you can't make it do that... so how is program 2 expecting the data already? Maybe you simply wanted to pass the contents of the array as individual arguments. But you are also using the pipe-to form, so will program 2 be reading from standard input? Without the pipe behavior, you can write: And have test-2 see the values as the contents of @ARGV. If you really do want to pass the data via standard input and the pipe, then your print statement would be: print FILE (join "\n",@$test); that is, write the contents of the array one value per line, which is how your existing test-2 is reading it.
In Section
Seekers of Perl Wisdom
|
|