Subject: | Unbuffered.pm Returns Unconnected File Handle |
Date: | Tue, 30 Jul 2013 23:32:55 +0200 |
To: | "bug-IO-Pager [...] rt.cpan.org bug-IO-Pager [...] rt.cpan.org" <bug-io-pager [...] rt.cpan.org> |
From: | "David E. Wheeler" <dwheeler [...] cpan.org> |
When IO::Pager detects no TTY, IO::Pager::Unbuffered returns an IO::Handle object. However, it neglects to hook up the handle to the file. This patch should fix that problem.
--- a/lib/IO/Pager/Unbuffered.pm
+++ b/lib/IO/Pager/Unbuffered.pm
@@ -16,7 +16,8 @@ sub new(;$) { # [FH], procedural
return $_[1] if defined($_[2]) && $_[2] eq 'procedural';
#...fall back to IO::Handle for transparent OO programming
- eval "require IO::Handle" && return new IO::Handle;
+ eval "require IO::Handle" or die $@;
+ return IO::Handle->new_from_fd(fileno($_[1]), 'w');
}
$!=$@, return 0 if $@ =~ 'pipe';
Best,
David