File Coverage

blib/lib/Env/Paths/2yaml.pm
Criterion Covered Total %
statement 27 45 60.0
branch 1 4 25.0
condition 8 15 53.3
subroutine 9 11 81.8
pod 0 1 0.0
total 45 76 59.2


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2             # Last modified: Tue Sep 02 2025 01:15:23 PM -04:00 [EDT]
3             # First created: Thu Jul 24 2025 12:47:02 PM -04:00 [EDT]
4              
5             {
6             package Env::Paths::2yaml;
7 1     1   7 use strict;
  1         2  
  1         35  
8 1     1   13 use v5.18;
  1         4  
9 1     1   7 use utf8;
  1         2  
  1         8  
10 1     1   39 use warnings;
  1         2  
  1         213  
11             our $VERSION = '0.35';
12             require Exporter;
13             our @ISA = qw(Exporter);
14             our @EXPORT = ();
15             our @EXPORT_OK = qw(ToYaml @Bare);
16             our (@Bare, @Wanted);
17              
18             =head1 SYNOPSIS
19              
20             C
21              
22             =cut
23              
24 1     1   8 no warnings 'redefine'; # Why are we seeing a warning here?:
  1         1  
  1         477  
25             sub ToYaml {
26 0     0 0   my $Key = shift;
27 0           my @pathels = @_;
28 0           my $header = qq[$Key] . qq[:\n];
29 0           my @listing = map { qq[ - $_\n] } grep { defined $_ } @pathels;
  0            
  0            
30 0           unshift( @listing, $header ) ;
31 0           return \@listing; # Ready to load as YAML
32             }
33              
34             } # /end of module pkg/
35              
36             # We're a modulino!
37             if (!caller() and $0 eq __FILE__)
38             {
39             package main;
40             # ---------------------- ### ---------------------- #
41             BEGIN {
42 2         7 @Wanted = map { push @Bare=> $_; q%@% .$_ } grep {
  2         58  
43 1 50 100 1   28 $_ eq "PERL5LIB"
  21   66     182  
      33        
      66        
44             || $_ eq "PATH"
45             || /^XDG_[A-Z]+_DIRS\z/
46             || ( /^[_A-Z0-9]+PATH\z/ && !/^XDG_.+_PATH\z/ )
47             || /PSModulePath/i
48             } sort keys %ENV;
49              
50             }
51             # ---------------------- ### ---------------------- #
52              
53             sub ::main {
54 1     1   14 use Env::Paths::2yaml;
  1         2  
  1         45  
55 1     1   4687 use YAML::Any;
  1         1987  
  1         4  
56             # It's nasty to hardcode it this way but this stuff in my env is just in the way:
57 0 0 0 0     @Bare = grep { $_ ne 'ORIGINAL_PATH'
  0            
58             && $_ ne 'AMDRMSDKPATH'
59             && $_ ne 'HOMEPATH' } @Bare;
60              
61 0           my $accumulator;
62 0           for my $kstr ( @Bare ) {
63 1     1   30328 no strict 'refs'; # a symbolic reference below:
  1         3  
  1         239  
64 0           my $seq = Env::Paths::2yaml::ToYaml( $kstr, @{$kstr} );
  0            
65 0           my $yaml_segment = join q[]=> @$seq;
66 0           $accumulator .= qq[\n---\n] . $yaml_segment;
67             }
68 0           printf "Line %s:\n", __LINE__;
69 0           print $accumulator;
70             }
71             ::main();
72             }
73              
74             1;
75             __END__