http://qs1969.pair.com?node_id=1187221


in reply to Track open file handles

There is a bug where it says...
@_ > 2 ? open $_[0],$_[1],$_[2] : open $_[0], $_[1];

open can accept more than two arguments (i.e. when piping to/from an external program), so, you should use instead...

@_ > 2 ? open $_[0],$_[1],@_[2..$#_] : open $_[0], $_[1];

Also, I am not sure that would work for the cases where the second argument is a string with a file handler embedded, as for instance open($fh, ">&STDOUT") or its three-args form open($fh, ">&", "STDOUT"). You will probably need to prefix those names with the calling package name.