Anthony wrote:
> Hi,
>
> what i'm creating is just an EXTREMELY script that sends an array to
> another script via PIPE.
Never coded in EXTREMELY before, but I'll have a go ;-)
> This is what i have:
>
> ################
> #! /usr/bin/perl
ALWAYS:
use strict;
use warnings;
> @file = qw (tony boby zombie anthony martine eric charlie);
> open(SORT, "| perl sorted.pl");
>
> while(@file){
> chomp $_;
> print SORT "$_\n";
> }
The test in your while condition, @file, is the number of elements
in the array. You loop will therefore execute indefinitely as the
array isn't empty. If you'd enabled warnings as I suggest above you
would have seen an endless steam of messages saying that $_ was
undefined within the loop, which would have bee a good hint.
You need something like:
foreach (@file) {
chomp;
print SORT "$_\n";
}
> 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 If you
> could write the code for me please.
No, I'm not going to write it for you, and I don't think most people
in the group would either as it would teach you nothing. Try it
yourself and we'll help you out if you get stuck.
> I tried, @ARGV - <STDIN> or shift but no luck. I really don't know
> how to do it
Well that's a good start. Anything piped into a Perl script (indeed
any p;rogram) like you've done appears on STDIN.
> Any help GREATLY appreciated, maybe my other script is also wrong,
Yes, maybe it is!
Cheers,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]