File Coverage

blib/lib/Filename/Audio.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Filename::Audio;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-05-30'; # DATE
5             our $DIST = 'Filename-Audio'; # DIST
6             our $VERSION = '0.003'; # VERSION
7              
8 1     1   57526 use 5.010001;
  1         11  
9 1     1   4 use strict;
  1         2  
  1         28  
10 1     1   5 use warnings;
  1         2  
  1         28  
11              
12 1     1   4 use Exporter qw(import);
  1         3  
  1         137  
13             our @EXPORT_OK = qw(check_audio_filename);
14              
15             # sorted by length then asciibetical
16             our $STR_RE = "mpega|aifc|aiff|flac|midi|mpga|opus|aif|amr|awb|axa|csd|gsm|kar|m3u|m4a|mid|mp2|mp3|oga|ogg|orc|pls|ram|sco|sd2|sid|snd|spx|wav|wax|wma|au|ra|rm"; # STR_RE
17             our $RE = qr(\.(?:$STR_RE)\z)i;
18              
19             sub check_audio_filename {
20 4     4 1 77 my %args = @_;
21              
22 4 100       44 $args{filename} =~ $RE ? {} : 0;
23             }
24              
25             1;
26             # ABSTRACT: Check whether filename indicates being an audio file
27              
28             __END__