<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 <joshua.mcadams@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Chicago.pm chatter <chicago-talk@pm.org><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 <<a ymailto="mailto:tigerpeng2001@yahoo.com" href="mailto:tigerpeng2001@yahoo.com">tigerpeng2001@yahoo.com</a>> wrote:<br>> I wrapped the open as below, and it works for the open $fh, $file but not<br>> open FH, $file.<br>><br>> As I need to apply the wrapping open function to lots of old script, I<br>> prefer only add one line: use myLoger 'open'; into the scripts<br>><br>> Is there any suggestion?<br>><br>> sub open{<br>> my ($package, $file, $line_number) = caller();<br>> my $fullpath = Cwd::abs_path($file);<br>> my $host =
hostname();<br>> _open_log({host=>hostname(),<br>> script=>Cwd::abs_path($file),<br>> file=>$_[1],<br>> }<br>> );<br>> CORE::open(shift, shift) or die "Cannot open : $!\n";<br>> }<br>><br>> sub _open_log {<br>> ...<br>> }<br>><br>><br>> ________________________________<br>> From: tiger peng <<a ymailto="mailto:tigerpeng2001@yahoo.com" href="mailto:tigerpeng2001@yahoo.com">tigerpeng2001@yahoo.com</a>><br>> To: <a target="_blank" href="http://Chicago.pm">Chicago.pm</a> chatter <<a ymailto="mailto:chicago-talk@pm.org"
href="mailto:chicago-talk@pm.org">chicago-talk@pm.org</a>><br>> Sent: Tue, October 19, 2010 11:41:10 AM<br>> Subject: [Chicago-talk] logging in and out files<br>><br>> Hello all,<br>><br>> Does anyone have the experience on tracing input/output files used by Perl<br>> script?<br>><br>> I am think if there is anyway to over write the build-in open function, so<br>> the new open function can log the file name, IO type (R, W, or RW), as well<br>> as the open/close timestamp. Any suggestion is highly appreciated.<br>><br>> Thanks,<br>> Tiger<br>><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><span>> <a target="_blank"
href="http://mail.pm.org/mailman/listinfo/chicago-talk">http://mail.pm.org/mailman/listinfo/chicago-talk</a></span><br>><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>