File Coverage

blib/lib/FindBin/Bin.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1             ########################################################################
2             # housekeeping
3             ########################################################################
4             package FindBin::Bin v0.1.0;
5 11     11   702127 use v5.40;
  11         42  
6              
7 11     11   1133 use parent qw( Exporter );
  11         916  
  11         128  
8              
9             use File::Spec::Functions
10             qw
11 11         2693 (
12             canonpath
13             catpath
14             curdir
15             rel2abs
16             splitpath
17 11     11   2711 );
  11         3205  
18              
19             BEGIN
20             {
21             # recall that $0 is an lvalue!!
22             # grab it quickly before it can change.
23             # this will not change during execution, compute it once.
24             #
25             # note that $0 defaults to a file path, never a directory.
26              
27 11 50   11   122 my $bin_from
28             = $0 =~ m{^ (?: -e | - | interactive ) }x
29             ? curdir
30             : ( splitpath $0 )[0,1]
31             ;
32              
33 11         287 our $Bin = canonpath rel2abs $bin_from;
34              
35 11     1 0 1961 eval qq/sub Bin(){ '$Bin' }/;
  1         1476  
  1         2  
  1         6  
36             }
37              
38             ########################################################################
39             # package variables & sanity checks
40             ########################################################################
41              
42             our @EXPORT_OK = qw( $Bin Bin );
43              
44             1
45             __END__