[Chicago-talk] logging in and out files

Joshua joshua.mcadams at gmail.com
Wed Oct 20 13:29:53 PDT 2010


I haven't done this myself before, but it looks like some folks have
and have put their work on CPAN:
http://search.cpan.org/~cwest/ex-override-1.1/override.pm

On Wed, Oct 20, 2010 at 9:55 AM, tiger peng <tigerpeng2001 at yahoo.com> wrote:
> 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
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


More information about the Chicago-talk mailing list