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-04-01'; # DATE
5             our $DIST = 'Filename-Audio'; # DIST
6             our $VERSION = '0.002'; # VERSION
7              
8 1     1   70075 use 5.010001;
  1         12  
9 1     1   5 use strict;
  1         2  
  1         33  
10 1     1   6 use warnings;
  1         2  
  1         29  
11              
12 1     1   5 use Exporter qw(import);
  1         2  
  1         172  
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 108 my %args = @_;
21              
22 4 100       86 $args{filename} =~ $RE ? {} : 0;
23             }
24              
25             1;
26             # ABSTRACT: Check whether filename indicates being an audio file
27              
28             __END__