Bartlomiej Frackiewicz wrote:
> Hi,
>
> sorry for my offtopic posting but i haven't found a general perl mailinglist (with
>some traffic).
>
> i want to spy my mod_perl/batch programs, in some case they write an error to STDERR
>i want to send an email to me.
>
> So i wrote Log.pm which has tie functions for handlers, but this doesnt work. it
>seems that perl donīt use print/printf/write functions for writing to STDERR. can
>someone point me to the right way?
try taking a look at recipes 6.10 and 16.6 in the mod_perl developer's
cookbook - 6.10 ties STDERR just as you do. 16.6 is available online
and explainswhy just tie()ing STDERR doesn't capture all possible
sources of writes to the error_log.
http://www.modperlcookbook.org/chapters/ch16.pdf
HTH
--Geoff
>
> Here is a piece of code to understand my idea:
>
> #!/usr/bin/perl -w
> use Log;
>
> tie (*STDERR, 'Log');
> if (0) {
> $w = 'lala';
> }
> print $w;
> untie (*STDERR);
>
> next we have Log.pm which has currently no email functions
>
> #!/usr/bin/perl -w
> package Log;
>
> sub TIEHANDLE {
> my $package = shift;
> print "tiehandle called\n";
>
> return bless {}, $package;
> }
>
> sub WRITE {
> my $r = shift;
> print STDOUT "write\n";
> }
>
> sub PRINT {
> my $r = shift;
> print STDOUT "print\n";
> }
>
> sub PRINTF {
> my $r = shift;
> print STDOUT "printf\n";
> }
>
> 1;
>
>
>