On 30 Aug 2007 at 10:59, Adriano Ferreira wrote:
> On 8/30/07, Beginner wrote:
> >
> > BEGIN { unshift @INC, '/etc/perl';
>
> This is better done with
>
> use lib qw(/etc/perl);
use lib ('/etc/perl');
Well that seems to work :-).
> which doesn't need the surrounding "BEGIN" block.
>
> > $| = 1;
> > open(STDERR, ">>/usr/local/myreports/report.log") || die
> > "Can't write to file: $!\n";
> > }
> >
> > use MY::MakePDF;
> > use MY::SendEmail;
> > use MY::Number;
> > use MY::PDF_Handler;
> > use File::Basename;
> > use strict;
> > use warnings;
> >
> > I want the STDERR from those modules to go to the log file also.
my $dist_dir = '/usr/local/myreports';
our $logfile = "$dist_dir/report.log";
INIT { open(STDERR, ">>$logfile") || die "Can't write to file: $!\n";
}
I tried the INIT option and that worked also and I liked the fact
that my `perl -c myscript.pl` sent it's output to screen and not my
log file and I can use a scalar for logfile.
q1) Does this still give me the effect of getting any errors from the
other modules directed to our $logfile?
q2) Will our $logfile now be a shared variable across all my modules?
q3) The $debug/verbose question: Will I have to pass subroutines in
other modules the $debug value if I am going to ask for more output,
or if I do the same to $debug as I did with $logfile, use our instead
of my. Will that allow those subroutines to check if debug is
enabled?
Sorry seem to have added more questions somehow?
Dp.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/