| 1 | #!perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use File::Spec::Functions qw[ catfile ]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 8 | my @fh = ( [ \*STDIN, '<' ], [ \*STDOUT, '>' ], [ \*STDERR, '>' ], ); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 8 | my %opt; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 8 | ▶ | GetOptions( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | \%opt, | ||||||||||||||||||||||||||||
| 17 | qw[ | ||||||||||||||||||||||||||||
| 18 | logdir=s | ||||||||||||||||||||||||||||
| 19 | long=s | ||||||||||||||||||||||||||||
| 20 | sleep=i | ||||||||||||||||||||||||||||
| 21 | s=s | ||||||||||||||||||||||||||||
| 22 | name=s | ||||||||||||||||||||||||||||
| 23 | ] ) or die; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | die( "must specify name\n" ) | ||||||||||||||||||||||||||||
| 26 | 8 | ▶ | unless defined $opt{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | die( "must specify logdir\n" ) | ||||||||||||||||||||||||||||
| 29 | 8 | ▶ | unless defined $opt{logdir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 8 | my %LOG = %opt; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 8 | ▶ | sleep( $opt{sleep} ) if defined $opt{sleep}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 8 | ▶ | while ( @ARGV ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 26 | my $fd = shift @ARGV; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | my ( $fh, $mode ) | ||||||||||||||||||||||||||||
| 41 | 26 | ▶ | = @{ $fh[$fd] | ||||||||||||||||||||||||||
|
Condition100%2/2
$fh[$fd] // ["IO::Handle"->new_from_fd($fd, $ARGV[0]), shift @ARGV]
MC/DC100%1/1
$fh[$fd] // ["IO::Handle"->new_from_fd($fd, $ARGV[0]), shift @ARGV]
$fh[$fd]
Truth table100%2/2
A
A= $fh[$fd]
| |||||||||||||||||||||||||||||
| 42 | // [ IO::Handle->new_from_fd( $fd, $ARGV[0] ), shift @ARGV ] }; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 26 | ▶ | die( "can't open $fd\n" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | unless defined $fh; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 26 | ▶ | if ( $mode eq '<' or $mode eq 'r' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$mode eq "<" or $mode eq "r"
MC/DC100%2/2
$mode eq "<" or $mode eq "r"
$mode eq "<"
$mode eq "r"
Truth table100%3/3
A or B
A= $mode eq "<"B= $mode eq "r"
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 7 | my @input = $fh->getlines; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 7 | $LOG{$fd} = \@input; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 7 | ▶ | print STDOUT @input if $fd == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 19 | $fh->say( "$opt{name} $fd" ); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 8 | my $logfile = catfile( $opt{logdir}, $opt{name} ) . ".log"; | |||||||||||||||||||||||||||
| 66 | 8 | ▶ | open( LOG, '>', $logfile ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | or die( "error creating $logfile\n" ); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 8 | print LOG Dumper( \%LOG ); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 8 | close LOG; | |||||||||||||||||||||||||||