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 17     17   353 use 5.016;
  17         71  
3             our $VERSION = '2.01';
4 17     17   134 use strict;
  17         61  
  17         519  
5 17     17   79 use warnings;
  17         28  
  17         1002  
6              
7 17     17   92 use Exporter 'import';
  17         29  
  17         1089  
8             our @EXPORT = qw(dir);
9              
10 17     17   96 use File::Spec;
  17         2089  
  17         4125  
11              
12             sub dir {
13              
14 42     42 1 92 my $dir = shift;
15              
16 42 50       1462 opendir my ($dh), $dir
17             or die "Failed to opendir $dir: $!\n";
18              
19             my @files =
20             sort
21 334         2667 map { File::Spec->catfile($dir, $_) }
22 42         1529 grep { $_ !~ /^\.\.?$/ }
  418         1207  
23             readdir $dh;
24              
25 42         585 closedir $dh;
26              
27 42         392 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