[Chicago-talk] logging in and out files

tiger peng tigerpeng2001 at yahoo.com
Thu Oct 21 10:34:45 PDT 2010


Thanks, it looks a good tool and I will try it later.

But my problem now is how to pass in and back the FH.

It complains with error message: 
Can't use string ("FH") as a symbol ref while "strict refs" in use at 
/my/lib/myLogger.pm ...

When I let it do not complain with "no strict 'refs';", it does not complain but 
FH seems not opened or not passed back, as the caller read nothing out.



________________________________
From: Joshua <joshua.mcadams at gmail.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Wed, October 20, 2010 3:29:53 PM
Subject: Re: [Chicago-talk] logging in and out files

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
>
_______________________________________________
Chicago-talk mailing list
Chicago-talk at pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20101021/e32874f1/attachment.html>


More information about the Chicago-talk mailing list