Your problem with strict comes from using symrefs for the handle names. Better to make the pipe with lexicals or, better yet, in a hash (untested):
It may be useful to use lexicals for their property of closing handles when they go out of scope:my $pipes = {}; for (qw/ ONE TWO THREE FOUR/) { pipe $pipes->{$_}{'FROM_CHILD'}, $pipes->{$_}{'TO_PARENT'}; #etc }
You might consider using a select loop instead of polling the kids.my $listen = {}; foreach $kid (qw/ ACE DEUCE TREY OOPS/ ) { $listen->{$kid} = do { my ($from,$to,$pid); pipe $from, $to; # fork and all, child closes $from, # deletes $listen, does child code and exits. { handle => $from, pid => $pid } }; }
As kappa says, this is all dependent on having a recent perl.
After Compline,
Zaxo
In reply to Re: FILEHANDLE with $var in name (for pipe)
by Zaxo
in thread FILEHANDLE with $var in name (for pipe)
by MadMax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |