| 1 | package IO::Barf; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use base qw(Exporter); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 3 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | ▶ | use Readonly; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | # Constants. | ||||||||||||||||||||
| 12 | 3 | Readonly::Array our @EXPORT => qw(barf); | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | our $VERSION = 0.10; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # Barf content to file. | ||||||||||||||||||||
| 17 | sub barf { | ||||||||||||||||||||
| 18 | 12 | ▶ | my ($file_or_handler, $content) = @_; | ||||||||||||||||||
|
Subroutine
barf: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | # File. | ||||||||||||||||||||
| 21 | 12 | my $ref = ref $file_or_handler; | |||||||||||||||||||
| 22 | 12 | ▶ | if (! $ref) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 23 | 4 | ▶ | open my $ouf, '>', $file_or_handler | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | or err "Cannot open file '$file_or_handler'."; | ||||||||||||||||||||
| 25 | 4 | print {$ouf} $content; | |||||||||||||||||||
| 26 | 4 | ▶ | close $ouf or err "Cannot close file '$file_or_handler'."; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | # Handler | ||||||||||||||||||||
| 29 | } elsif ($ref eq 'GLOB') { | ||||||||||||||||||||
| 30 | 3 | print {$file_or_handler} $content; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # IO::Handle. | ||||||||||||||||||||
| 33 | ▶ | } elsif (blessed($file_or_handler) | |||||||||||||||||||
|
Condition100%3/3
builtin::blessed($file_or_handler) and $file_or_handler->isa("IO::Handle")
MC/DC100%2/2
builtin::blessed($file_or_handler) and $file_or_handler->isa("IO::Handle")
builtin::blessed($file_or_handler)
$file_or_handler->isa("IO::Handle")
Truth table100%3/3
A and B
A= builtin::blessed($file_or_handler)B= $file_or_handler->isa("IO::Handle")
| |||||||||||||||||||||
| 34 | && $file_or_handler->isa('IO::Handle')) { | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 3 | $file_or_handler->print($content); | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | # Other. | ||||||||||||||||||||
| 39 | } else { | ||||||||||||||||||||
| 40 | 2 | err "Unsupported reference '$ref'."; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 10 | return; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 3 | 1; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||