Anthony wrote:
>
> Hi,
Hello,
> what i'm creating is just an EXTREMELY script that sends an array to another
> script via PIPE.
> This is what i have:
>
> ################
> #! /usr/bin/perl
use warnings;
use strict;
> @file = qw (tony boby zombie anthony martine eric charlie);
It seems like you need newlines at the end of each element.
my @file = <<FILE;
tony
boby
zombie
anthony
martine
eric
charlie
FILE
> open(SORT, "| perl sorted.pl");
You should _always_ verify that the pipe opened AND closed correctly.
open SORT, '| perl sorted.pl' or die "Cannot open pipe to 'perl
sorted.pl' $!";
> while(@file){
> chomp $_;
There is nothing in the data TO chomp;
> print SORT "$_\n";
> }
If you include the newlines as I showed above then:
print SORT @file;
close SORT or die "Cannot close pipe to 'perl sorted.pl' $!";
> print "DID it WORKed??";
> ###########################
>
> Now in my other script called sorted. pl i'm using the "sort" command to
> sort the array. But my question is How should i write the sorted.pl script
> to received the data and then send it back
You can't. Pipes only work in one direction. If you want
bi-directional data transfer then look at IPC::Open2 or IPC::Open3 and
read the perlipc document for alternatives.
perldoc IPC::Open2
perldoc IPC::Open3
perldoc perlipc
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]