<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>I wrapped the open as below, and it works for the <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">open $fh, $file</span> but not <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">open FH, $file</span>.<br><br>As I need to apply the wrapping open function to lots of old script, I prefer only add one line: <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">use myLoger 'open';</span> into the scripts<br><br>Is there any suggestion?<br><br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">sub open{</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my ($package, $file, $line_number)
 = caller();</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my $fullpath&nbsp; = Cwd::abs_path($file);</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; my $host = hostname();</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; _open_log({host=&gt;hostname(),</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; script=&gt;Cwd::abs_path($file),</span><br style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file=&gt;$_[1],</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">&nbsp;&nbsp;&nbsp; CORE::open(shift, shift) or die "Cannot open : $!\n";</span><br style="font-family: Courier
 New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">}</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">sub _open_log {</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">...</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">}</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr
 size="1"><b><span style="font-weight: bold;">From:</span></b> tiger peng &lt;tigerpeng2001@yahoo.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> Chicago.pm chatter &lt;chicago-talk@pm.org&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Tue, October 19, 2010 11:41:10 AM<br><b><span style="font-weight: bold;">Subject:</span></b> [Chicago-talk] logging in and out files<br></font><br>
<div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: rgb(0, 0, 191);"><div>Hello all,<br><br>Does anyone have the experience on tracing input/output files used by Perl script?<br><br>I am think if there is anyway to over write the build-in open function, so the new open function can log the file name, IO type (R, W, or RW), as well as the open/close timestamp. Any suggestion is highly appreciated. <br><br>Thanks,<br>Tiger<br></div>
</div></div></div>
</div></body></html>