| 1 | package IO::Pager::Unbuffered; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | our $VERSION = 1.04; #Untouched since 1.02 | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use base qw( IO::Pager ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use SelectSaver; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | sub new(;$) { # [FH], procedural | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | my($class, $tied_fh); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | eval { ($class, $tied_fh) = &IO::Pager::_init }; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | #We're not on a TTY so... | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | if( defined($class) && $class eq '0' or $@ =~ '!TTY' ){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $class and $class eq 0 or $@ =~ /!TTY/
defined $class and $class eq 0
MC/DC0%0/3
defined $class and $class eq 0 or $@ =~ /!TTY/
defined $class
$class eq 0
$@ =~ /!TTY/
Truth table40%2/5
A and B or C
A= defined $classB= $class eq 0C= $@ =~ /!TTY/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #...leave filehandle alone if procedural | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | return $_[1] if defined($_[2]) && $_[2] eq 'procedural'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[2] and $_[2] eq "procedural"
MC/DC0%0/2
defined $_[2] and $_[2] eq "procedural"
defined $_[2]
$_[2] eq "procedural"
Truth table33%1/3
A and B
A= defined $_[2]B= $_[2] eq "procedural"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #...fall back to IO::Handle for transparent OO programming | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | eval "require IO::Handle" or die $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | return IO::Handle->new_from_fd(fileno($_[1]), 'w'); | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | $!=$@, return 0 if $@ =~ 'pipe'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | my $self = tie *$tied_fh, $class, $tied_fh or return 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | { # Truly unbuffered | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my $saver = SelectSaver->new($self->{real_fh}); | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | $|=1; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | 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 | ▶ | &new('IO::Pager::procedural', $_[0], 'procedural'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||