[guest - Tue Nov 15 17:00:56 2005]:
The attached file will illustrate the problem. I wasn't clever enough
(Don't be clever - pg 453) to figure out how to cascade a compile-time
error to Test::More, and I wasn't able to figure out how to use the tied
hashes in IO::FILE (Don't tie variables or filehandles - pg 451) enough
to suggest a work-around. (P.S. Thanks for counterindicating tieing.
I never dug into it enough to understand, or use, it. I now have a
good reason not to.)
In the mean time, this file can illustrate how compile-time
configuration does work, but run-time configuration does *not* work.
Let me know if there's more assistance I can provide.
Thanks,
Michael Wolf
#! /usr/bin/perl
use warnings;
use strict;
use Test::More tests => 8;
use File::stat;
use File::Temp qw(tempfile);
my($fh, $filename) = tempfile();
ok($filename, "File name is populated as '$filename'...");
ok(-f $filename, "...and it's a file");
ok(-w $filename, "...and it's writable.");
ok($fh, "File handle is populated...");
ok(-f $fh, "...and it's a file");
ok(-w $fh, "...and it's writable.");
my $statref;
$statref = stat($filename);
cmp_ok($statref->size, '==', 0, "File is initally empty checking file name.");
$statref = stat($fh);
cmp_ok($statref->size, '==', 0, "File is initally empty checking file handle.");
# Uncomment one, and only one, of the following.
#
#use Log::StdLog; # OK
use Log::StdLog { file => "$0.log" }; # OK
#use Log::StdLog { file => $filename }; # NOT OK
my $print_rc = print {*STDLOG} warn => "warn";
ok($print_rc, "Meessage was logged as warn level.");
flush STDLOG;
$statref = stat($filename);
cmp_ok($statref->size, '!=', 0, "File is initally empty checking file name.");
$statref = stat($fh);
cmp_ok($statref->size, '!=', 0, "File is initally empty checking file handle.");
close $fh;
unlink $filename;