Re: How do I output an array twice via pipe instead of only once?



The solution: I noticed a few inconsistent results that still occured
occasionally but not every time I ran it. I think another issue
(perhaps THE issue) was my slack usage of "open". I added a couple
extra open and close statements which solved that. I was able to leave
b.pl as to how I had it originally (for other reasons). Here is my
final working version of a.pl and b.pl:
Now I'm happy!

#!/usr/bin/perl -w
#
# a.pl
#

open(OUTPUT,"|b.pl");

@array1=("A","B");
print OUTPUT "@array1", "\n";

close(OUTPUT);

open(OUTPUT,"|b.pl");

@array2=("C","D");
print OUTPUT "@array2", "\n";

close(OUTPUT);

----------------------------------------------

#!/usr/bin/perl -w
#
# b.pl
#

@input=<STDIN>;
print "here is the inputted array: @input \n";

-----------------------------------------------

Output:
here is the inputted array: A B

here is the inputted array: C D

-----------------------------------------------

.