# use strict; # I turned off strict because I get the following error with it on: # Can't use string ("FROM_CHILD_ONE") as a symbol ref while # "strict refs" in use at foo.pl line 16. Strict off seems to work?? my %hash; my @dirs; @dirs = qw(ONE TWO THREE FOUR); for my $loop(@dirs) { my $from = "FROM_CHILD_$loop"; my $to = "TO_PARENT_$loop"; pipe ($from, $to) or die "Oops Pipe: $!\n"; select((select($to), $|++ )[0]); # set autoflush $|++; my $test = rand 5; # simulate processing print $to "$test $loop\n"; } for my $loop(@dirs) { my $from = "FROM_CHILD_$loop"; my $to = "TO_PARENT_$loop"; chomp( my $in = <$from> ); (my $value, my $key) = split(/\ /, $in); $hash{$key} = $value; close $to; close $from; } for my $loop(keys %hash) { print "keys $loop => $hash{$loop}\n"; }