| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package IO::Pager::Unbuffered; | 
| 2 |  |  |  |  |  |  | our $VERSION = 1.04; #Untouched since 1.02 | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 3 |  |  | 3 |  | 1166 | use strict; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 93 |  | 
| 5 | 3 |  |  | 3 |  | 16 | use warnings; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 91 |  | 
| 6 | 3 |  |  | 3 |  | 15 | use base qw( IO::Pager ); | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 415 |  | 
| 7 | 3 |  |  | 3 |  | 929 | use SelectSaver; | 
|  | 3 |  |  |  |  | 515 |  | 
|  | 3 |  |  |  |  | 937 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | sub new(;$) {  # [FH], procedural | 
| 11 | 4 |  |  | 4 | 1 | 10 | my($class, $tied_fh); | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 4 |  |  |  |  | 8 | eval { ($class, $tied_fh) = &IO::Pager::_init }; | 
|  | 4 |  |  |  |  | 13 |  | 
| 14 |  |  |  |  |  |  | #We're not on a TTY so... | 
| 15 | 4 | 100 | 66 |  |  | 39 | if( defined($class) && $class eq '0' or $@ =~ '!TTY' ){ | 
|  |  |  | 66 |  |  |  |  | 
| 16 |  |  |  |  |  |  | #...leave filehandle alone if procedural | 
| 17 | 2 | 50 | 33 |  |  | 12 | return $_[1] if defined($_[2]) && $_[2] eq 'procedural'; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | #...fall back to IO::Handle for transparent OO programming | 
| 20 | 2 | 50 |  |  |  | 111 | eval "require IO::Handle" or die $@; | 
| 21 | 2 |  |  |  |  | 4339 | return IO::Handle->new_from_fd(fileno($_[1]), 'w'); | 
| 22 |  |  |  |  |  |  | } | 
| 23 | 2 | 50 |  |  |  | 8 | $!=$@, return 0 if $@ =~ 'pipe'; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 2 | 0 |  |  |  | 17 | my $self = tie *$tied_fh, $class, $tied_fh or return 0; | 
| 26 |  |  |  |  |  |  | { # Truly unbuffered | 
| 27 | 0 |  |  |  |  |  | my $saver = SelectSaver->new($self->{real_fh}); | 
|  | 0 |  |  |  |  |  |  | 
| 28 | 0 |  |  |  |  |  | $|=1; | 
| 29 |  |  |  |  |  |  | } | 
| 30 | 0 |  |  |  |  |  | return $self; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | #Punt to base, preserving FH ($_[0]) for pass by reference to gensym | 
| 34 |  |  |  |  |  |  | sub open(;$) { # [FH] | 
| 35 |  |  |  |  |  |  | #  IO::Pager::open($_[0], 'IO::Pager::Unbuffered'); | 
| 36 | 0 |  |  | 0 | 1 |  | &new('IO::Pager::procedural', $_[0], 'procedural'); | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | 1; | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | __END__ |