script/sponge

filter: Statementstmt 96.6% 29 / 30 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 92.5% 37 / 40 CC 1 SCAR 0.0
CC
1
Cov
92%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary blib/lib/App/sponge.pm »
1 #!perl
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7 2 our $DATE = '2023-02-15'; # DATE
8 2 our $DIST = 'App-sponge'; # DIST
9 2 our $VERSION = '0.003'; # VERSION
10  
11 2 ▶use Fcntl qw(:DEFAULT);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Getopt::Std;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 my %opts;
15 2 ▶getopts('a', \%opts) or die "sponge: Error in options processing, bailing\n";
Branch: 1 branch
BranchTrueFalseTotal
&getopts("a", \%opts) or die "sponge: Error in options processing, bailing\n" 2 0 2
16  
17 # soak input first
18 2 my $input; { local $/; $input = <STDIN> }
19  
20 2 ▶if (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) { } 2 0 2
21 2 my $fh;
22 2 ▶ if ($opts{a}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'a'}) { } 1 1 2
23 1 sysopen $fh, $ARGV[0], O_CREAT|O_WRONLY;
24 1 seek $fh, 0, 2;
25 } else {
26 1 sysopen $fh, $ARGV[0], O_CREAT|O_TRUNC|O_WRONLY;
27 }
28 2 print $fh $input;
29 } else {
30 # print to stdout
31 0 print $input;
32 }
33  
34 # ABSTRACT: Soak up standard input and write to a file (perl implementation)
35 # PODNAME: sponge
36  
37 __END__
↑ Summary blib/lib/App/sponge.pm »