Subject: | warning while checking empty file contents with file_contents_is |
Date: | Tue, 03 Nov 2009 15:52:03 +0300 |
To: | bug-test-file-contents [...] rt.cpan.org |
From: | Evgeniy Kosov <evgeniy [...] kosov.su> |
Hi,
The log below show how to reproduce the warning.
# touch /tmp/empty_file
# cat > empty_file.t
#!perl
use Test::More tests => 1;
use Test::File::Contents;
file_contents_is('/tmp/empty_file', '', 'empty file');
^D
# perl empty_file.t
1..1
Use of uninitialized value in string eq at
/usr/local/lib/perl5/site_perl/5.10.0/Test/File/Contents.pm line 58.
ok 1 - empty file
Explicitly specifying call context for <> helped (see the patch below).
Though this is just a warning and it doesn't affect the module's correct
behavior, some people (me included) can find them irritating, so I
decided to send I this patch...
--- lib/Test/File/Contents.pm-orig 2009-11-03 15:23:49.000000000 +0300
+++ lib/Test/File/Contents.pm 2009-11-03 15:23:29.000000000 +0300
@@ -209,7 +209,7 @@
local *IN;
if (open IN, $file) {
local $/ = undef;
- if ($code->(<IN>)) {
+ if ($code->(scalar <IN>)) {
$Test->ok(1, $desc);
return 1;
} else {
Thank you for your time and an excellent module! :)
--
BR,
Evgeniy Kosov