MadMax has asked for the wisdom of the Perl Monks concerning the following question:
use strict; my %hash; my @dirs; @dirs = qw(ONE TWO THREE FOUR); for my $loop(@dirs) { pipe (FROM_CHILD_$loop, TO_PARENT_$loop) or die "Oops Pipe: $!\n"; select((select(TO_PARENT_$loop), $|++ )[0]); # set autoflush $|++; my $test = rand 5; # simulate processing print TO_PARENT_$loop "$test $loop\n"; } for my $loop(@dirs) { chomp( my $in = <FROM_CHILD_$loop> ); (my $value, my $key) = split(/\ /, $in); $hash{$key} = $value; } close FROM_CHILD_$loop; close TO_PARENT_$loop; for my $loop(keys %hash) { print "keys $loop => $hash{$loop}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FILEHANDLE with $var in name (for pipe)
by moodster (Hermit) on Apr 05, 2002 at 11:22 UTC | |
by kappa (Chaplain) on Apr 05, 2002 at 12:05 UTC | |
|
Re: FILEHANDLE with $var in name (for pipe)
by mla (Beadle) on Apr 05, 2002 at 12:38 UTC | |
|
Re: FILEHANDLE with $var in name (for pipe)
by MadMax (Novice) on Apr 05, 2002 at 11:22 UTC | |
|
Re: FILEHANDLE with $var in name (for pipe)
by Zaxo (Archbishop) on Apr 05, 2002 at 13:10 UTC |