in reply to Debug openings and closings

You can override CORE::open and close. The following should get you going:

BEGIN { *CORE::GLOBAL::open = \&my_open; sub my_open(*;$@) { my ( undef, $filename, $line ) = caller; print "opening $_[2] in $filename:$line\n"; CORE::open($_[0], $_[1], $_[2]); } } open my $fh, "<", "temp~" or die $!;

Googling came up with Testing Legacy Code