# This is oversimplified but should work. # The $command string is generated each time # The $handle is supposed to be an anon file handle. use IO::File; for($f=0; $f<10; $f++){ my $handle = IO::File -> new(); open($handle, "$command |"); }