File Coverage

blib/lib/EBook/Ishmael/Dir.pm
Criterion Covered Total %
statement 21 21 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 29 30 96.6


line stmt bran cond sub pod time code
1             package EBook::Ishmael::Dir;
2 18     18   993 use 5.016;
  18         77  
3             our $VERSION = '2.03';
4 18     18   146 use strict;
  18         36  
  18         503  
5 18     18   94 use warnings;
  18         29  
  18         1039  
6              
7 18     18   95 use Exporter 'import';
  18         48  
  18         1026  
8             our @EXPORT = qw(dir);
9              
10 18     18   131 use File::Spec;
  18         54  
  18         4205  
11              
12             sub dir {
13              
14 60     60 1 267445 my $dir = shift;
15              
16 60 50       3154 opendir my ($dh), $dir
17             or die "Failed to opendir $dir: $!\n";
18              
19             my @files =
20             sort
21 404         2996 map { File::Spec->catfile($dir, $_) }
22 60         2344 grep { $_ !~ /^\.\.?$/ }
  524         1347  
23             readdir $dh;
24              
25 60         1022 closedir $dh;
26              
27 60         485 return @files;
28              
29             }
30              
31             1;
32              
33             =head1 NAME
34              
35             EBook::Ishmael::Dir - Get list of files from directory
36              
37             =head1 SYNOPSIS
38              
39             use EBook::Ishmael::Dir;
40              
41             my @files = dir('/');
42              
43             =head1 DESCRIPTION
44              
45             B is a module that provides the C subroutine. This
46             is developer documentation, for L user documentation you should consult
47             its manual.
48              
49             =head1 SUBROUTINES
50              
51             =over 4
52              
53             =item @f = dir($dir)
54              
55             Returns list of files in C<$dir>, sorted. Don't sort the list it returns, for
56             some reason the list decays into C<$dir>. No idea why.
57              
58             =back
59              
60             =head1 AUTHOR
61              
62             Written by Samuel Young, Esamyoung12788@gmail.comE.
63              
64             This project's source can be found on its
65             L. Comments and pull
66             requests are welcome!
67              
68             =head1 COPYRIGHT
69              
70             Copyright (C) 2025-2026 Samuel Young
71              
72             This program is free software: you can redistribute it and/or modify
73             it under the terms of the GNU General Public License as published by
74             the Free Software Foundation, either version 3 of the License, or
75             (at your option) any later version.
76              
77             =cut