<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:Courier New,courier,monaco,monospace,sans-serif;font-size:10pt"><div style="font-family: Courier New,courier,monaco,monospace,sans-serif; font-size: 10pt;"><span style="font-family: arial,helvetica,sans-serif;">Thanks, it looks a good tool and I will try it later.</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">But my problem now is how to pass in and back the FH.</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">It complains with error message: </span><br>Can't use string ("FH") as a symbol ref while "strict refs" in use at /my/lib/myLogger.pm ...<br><br><span style="font-family: arial,helvetica,sans-serif;">When I
 let it do not complain with <span style="font-family: Courier New,courier,monaco,monospace,sans-serif;">"</span></span>no strict 'refs';", <span style="font-family: arial,helvetica,sans-serif;">it does not complain but FH seems not opened or not passed back, as the caller read nothing out.</span><br><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Joshua &lt;joshua.mcadams@gmail.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> Wed, October 20, 2010 3:29:53 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Chicago-talk] logging in and out files<br></font><br>
I haven't done this myself before, but it looks like some folks have<br>and have put their work on CPAN:<br><span><a target="_blank" href="http://search.cpan.org/%7Ecwest/ex-override-1.1/override.pm">http://search.cpan.org/~cwest/ex-override-1.1/override.pm</a></span><br><br>On Wed, Oct 20, 2010 at 9:55 AM, tiger peng &lt;<a ymailto="mailto:tigerpeng2001@yahoo.com" href="mailto:tigerpeng2001@yahoo.com">tigerpeng2001@yahoo.com</a>&gt; wrote:<br>&gt; I wrapped the open as below, and it works for the open $fh, $file but not<br>&gt; open FH, $file.<br>&gt;<br>&gt; As I need to apply the wrapping open function to lots of old script, I<br>&gt; prefer only add one line: use myLoger 'open'; into the scripts<br>&gt;<br>&gt; Is there any suggestion?<br>&gt;<br>&gt; sub open{<br>&gt; &nbsp;&nbsp;&nbsp; my ($package, $file, $line_number) = caller();<br>&gt; &nbsp;&nbsp;&nbsp; my $fullpath&nbsp; = Cwd::abs_path($file);<br>&gt; &nbsp;&nbsp;&nbsp; my $host =
 hostname();<br>&gt; &nbsp;&nbsp;&nbsp; _open_log({host=&gt;hostname(),<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; script=&gt;Cwd::abs_path($file),<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file=&gt;$_[1],<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br>&gt; &nbsp;&nbsp;&nbsp; CORE::open(shift, shift) or die "Cannot open : $!\n";<br>&gt; }<br>&gt;<br>&gt; sub _open_log {<br>&gt; ...<br>&gt; }<br>&gt;<br>&gt;<br>&gt; ________________________________<br>&gt; From: tiger peng &lt;<a ymailto="mailto:tigerpeng2001@yahoo.com" href="mailto:tigerpeng2001@yahoo.com">tigerpeng2001@yahoo.com</a>&gt;<br>&gt; To: <a target="_blank" href="http://Chicago.pm">Chicago.pm</a> chatter &lt;<a ymailto="mailto:chicago-talk@pm.org"
 href="mailto:chicago-talk@pm.org">chicago-talk@pm.org</a>&gt;<br>&gt; Sent: Tue, October 19, 2010 11:41:10 AM<br>&gt; Subject: [Chicago-talk] logging in and out files<br>&gt;<br>&gt; Hello all,<br>&gt;<br>&gt; Does anyone have the experience on tracing input/output files used by Perl<br>&gt; script?<br>&gt;<br>&gt; I am think if there is anyway to over write the build-in open function, so<br>&gt; the new open function can log the file name, IO type (R, W, or RW), as well<br>&gt; as the open/close timestamp. Any suggestion is highly appreciated.<br>&gt;<br>&gt; Thanks,<br>&gt; Tiger<br>&gt;<br>&gt; _______________________________________________<br>&gt; Chicago-talk mailing list<br>&gt; <a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br><span>&gt; <a target="_blank"
 href="http://mail.pm.org/mailman/listinfo/chicago-talk">http://mail.pm.org/mailman/listinfo/chicago-talk</a></span><br>&gt;<br>_______________________________________________<br>Chicago-talk mailing list<br><a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br></div></div>
</div></body></html>