File Coverage

blib/lib/App/PTP/PerlEnv.pm
Criterion Covered Total %
statement 22 34 64.7
branch 0 8 0.0
condition 0 4 0.0
subroutine 8 12 66.6
pod 0 6 0.0
total 30 64 46.8


line stmt bran cond sub pod time code
1             # This package is the one that provides the symbol accessible to the user
2             # supplied Perl code. The global variables are manipulated and set by the
3             # App::PTP::Commands package.
4            
5             package App::PTP::PerlEnv;
6              
7 20     20   139 use strict;
  20     18   50  
  20         673  
  18         21584  
  1         306  
  1         5  
8 20     20   120 use warnings;
  20     1   45  
  20         779  
  1         2950  
  1         167  
  1         4  
9              
10 20     20   106 use Exporter 'import';
  20     1   50  
  20         6633  
  1         964  
  1         46  
  1         4  
11              
12             my @all_symbols = qw($f $F $n $N $m $. @m $I ss pf spf $PerlEnv_LOADED);
13             our @EXPORT = ();
14             # This array is read directly to share all these symbols with the Safe.
15             our @EXPORT_OK = @all_symbols;
16             our %EXPORT_TAGS = (all => \@all_symbols);
17             # Marker that can be checked to know if the module is loaded.
18             our $PerlEnv_LOADED = 1;
19              
20             our $f; # This will be the name of the processed file, shared with the safe.
21             our $F; # The absolute path to the input file.
22             our $n; # This will be the current line number, shared with the safe.
23             our $N; # This will be the total number of lines of the input.
24             our $m; # The marker of the current line.
25             our $.; # The standard name for the $n variable.
26             our @m; # The read-only version of @markers (with read relative).
27             our $I; # The index of the file being processed.
28              
29             sub ss ($;$$) {
30 0     0 0 0 my ($start, $len, $str) = @_;
  0     0 0 0  
31 0 0       0 $str = $_ unless defined $str;
  0 0       0  
32 0 0       0 $len = length($str) unless $len;
  0 0       0  
33             # print "start=${start}; len=${len}; str=${str}\n";
34             # substr returns undef for sub-strings outside the original string. This would
35             # remove the input line, so instead we're keeping an empty string.
36 0   0     0 substr($str, $start, $len) // '';
  0   0     0  
37             }
38              
39             sub pf($@) {
40 3     3 0 9 my ($format, @args) = @_;
  0     0 0 0  
41             # print "format=${format} args=(".join(', ', @args).")\n";
42 3         19 $_ = sprintf $format, @args;
  0         0  
43             }
44              
45             sub spf($@) {
46 2     2 0 17 my ($format, @args) = @_;
  0     0 0    
47             # print "format=${format} args=(".join(', ', @args).")\n";
48 2         25 sprintf $format, @args;
  0            
49             }
50              
51             1;