File Coverage

lib/File/Filename.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition 1 5 20.0
subroutine 3 3 100.0
pod 0 1 0.0
total 21 27 77.7


line stmt bran cond sub pod time code
1             package File::Filename;
2 1     1   20541 use strict;
  1         2  
  1         40  
3             require Exporter;
4 1     1   6 use vars qw(@ISA @EXPORT_OK $VERSION $delimiter);
  1         1  
  1         8696  
5             @ISA = qw(Exporter);
6             @EXPORT_OK = (qw(get_filename_segments));
7             $VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)/g;
8              
9             $delimiter = qr/[^a-zA-Z0-9 ]+/;
10              
11             sub get_filename_segments {
12 65     65 0 13266 my $filename = shift;
13 65 50 0     127 $filename or warn('get_fields_arrayref() no arg.') and return;
14 65         71 my $delimiters = shift;
15 65   33     218 $delimiters ||= $delimiter;
16              
17 65         98 $filename=~s/\/+$//;
18 65         90 $filename=~s/^.+\/+//; # take out slashes if present
19            
20             [
21 332         3858 map { $_=~s/^\s+|\s+$//g; $_ }
  332         653  
  332         782  
22 65         566 grep { /./ } # dont use empty elements
23             split( /$delimiters/, $filename)
24             ]
25             }
26              
27             1;
28              
29             __END__