[Chicago-talk] logging in and out files

tiger peng tigerpeng2001 at yahoo.com
Wed Oct 20 07:55:44 PDT 2010


I wrapped the open as below, and it works for the open $fh, $file but not open 
FH, $file.

As I need to apply the wrapping open function to lots of old script, I prefer 
only add one line: use myLoger 'open'; into the scripts

Is there any suggestion?

sub open{
    my ($package, $file, $line_number) = caller();
    my $fullpath  = Cwd::abs_path($file);
    my $host = hostname();
    _open_log({host=>hostname(),
               script=>Cwd::abs_path($file),
               file=>$_[1],
              }
              );
    CORE::open(shift, shift) or die "Cannot open : $!\n";
}

sub _open_log {
...
}





________________________________
From: tiger peng <tigerpeng2001 at yahoo.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Tue, October 19, 2010 11:41:10 AM
Subject: [Chicago-talk] logging in and out files


Hello all,

Does anyone have the experience on tracing input/output files used by Perl 
script?

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. 


Thanks,
Tiger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20101020/b2a69ef3/attachment.html>


More information about the Chicago-talk mailing list