blib/lib/EBook/Ishmael/Dir.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 96.9% 32 / 33 CC 2 SCAR 2.5
CC
2
Cov
96%
dir
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/EBook/Ishmael/EBook.pm ↑ Summary blib/lib/EBook/Ishmael/EBook/CBZ.pm »
1 package EBook::Ishmael::Dir;
2 18 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 our $VERSION = '2.03';
4 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 our @EXPORT = qw(dir);
9  
10 18 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub dir {
13  
14 60 ▶ my $dir = shift;
Subroutine dir: called CC=2 SCAR=7.0
Pod documented
15  
16 60 ▶ opendir my ($dh), $dir
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $dir or die "Failed to opendir ${dir}: $!\n" 0 60 60
17 or die "Failed to opendir $dir: $!\n";
18  
19 my @files =
20 sort
21 404 map { File::Spec->catfile($dir, $_) }
22 60 grep { $_ !~ /^\.\.?$/ }
23 readdir $dh;
24  
25 60 closedir $dh;
26  
27 60 return @files;
28  
29 }
30  
31 18 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<EBook::Ishmael::Dir> is a module that provides the C<dir()> subroutine. This
46 is developer documentation, for L<ishmael> 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, E<lt>samyoung12788@gmail.comE<gt>.
63  
64 This project's source can be found on its
65 L<Codeberg Page|https://codeberg.org/1-1sam/ishmael>. 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
« blib/lib/EBook/Ishmael/EBook.pm ↑ Summary blib/lib/EBook/Ishmael/EBook/CBZ.pm »