|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Music::Tag::Generic;  | 
| 
2
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
29
 | 
 use strict; use warnings; use utf8;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
200
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
188
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
26
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '.4101';  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Copyright © 2007,2008,2009,2010 Edward Allen III. Some rights reserved.  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # You may distribute under the terms of either the GNU General Public  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # License or the Artistic License, as specified in the README file.  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
234
 | 
 use Encode;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
526
 | 
    | 
| 
13
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
39
 | 
 use vars qw($AUTOLOAD);  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
252
 | 
    | 
| 
14
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
38
 | 
 use Scalar::Util qw(weaken);  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
434
 | 
    | 
| 
15
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
29
 | 
 use Carp;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22976
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
18
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $class   = shift;  | 
| 
19
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $parent  = shift;  | 
| 
20
 | 
0
 | 
 
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
     my $options = shift || {};  | 
| 
21
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $self    = {};  | 
| 
22
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     bless $self, $class;  | 
| 
23
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $self->info($parent);  | 
| 
24
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $self->options($options);  | 
| 
25
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $self;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub info {  | 
| 
29
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
30
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $val  = shift;  | 
| 
31
 | 
0
 | 
  
  0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
     if ( defined $val && ref $val ) {  | 
| 
32
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $self->{info} = $val;  | 
| 
33
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         weaken $self->{info};  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
35
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $self->{info};  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub required_values {  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
41
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub set_values {  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub saved_values {  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub get_tag {  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
50
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub set_tag {  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
53
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub strip_tag {  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
56
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub close {  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub tagchange {  | 
| 
60
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
61
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $tag  = lc(shift);  | 
| 
62
 | 
0
 | 
 
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
     my $to   = shift || $self->info->get_data($tag) || "";  | 
| 
63
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $self->status( $self->info->_tenprint( $tag, 'bold blue', 15 ) . '"' . $to . '"' );  | 
| 
64
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $self->info->changed(1);  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub simplify {  | 
| 
68
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
69
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $text = shift;  | 
| 
70
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     chomp $text;  | 
| 
71
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $text unless $text;  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
73
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $self->options->{Unaccent} ) {  | 
| 
74
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text = Text::Unaccent::PurePerl::unac_string($text);  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
77
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text = lc($text);  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
79
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\[[^\]]+\]//g;  | 
| 
80
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/[\s_]/ /g;  | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
82
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( length($text) > 5 ) {  | 
| 
83
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\bthe\s//g;  | 
| 
84
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\ba\s//g;  | 
| 
85
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\ban\s//g;  | 
| 
86
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\band\s//g;  | 
| 
87
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\ble\s//g;  | 
| 
88
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\bles\s//g;  | 
| 
89
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\bla\s//g;  | 
| 
90
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\bde\s//g;  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
92
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $self->options->{Inflect} ) {  | 
| 
93
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/(\.?\d+\,?\d*\.?\d*)/Lingua::EN::Inflect::NUMWORDS($1)/egxms;  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     else {  | 
| 
96
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b10\s/ten /g;  | 
| 
97
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b9\s/nine /g;  | 
| 
98
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b8\s/eight /g;  | 
| 
99
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b7\s/seven /g;  | 
| 
100
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b6\s/six /g;  | 
| 
101
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b5\s/five /g;  | 
| 
102
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b4\s/four /g;  | 
| 
103
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b3\s/three /g;  | 
| 
104
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b2\s/two /g;  | 
| 
105
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $text =~ s/\b1\s/one /g;  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
108
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\sii\b/two/g;  | 
| 
109
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\siii\b/three/g;  | 
| 
110
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\siv\b/four/g;  | 
| 
111
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\sv\b/five/g;  | 
| 
112
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\svi\b/six/g;  | 
| 
113
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\svii\b/seven/g;  | 
| 
114
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/\sviii\b/eight/g;  | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
116
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # Don't translate IX because of a soft spot in my heart for the technologically rich planet.  | 
| 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
118
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $text =~ s/[^a-z0-9]//g;  | 
| 
119
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $text;  | 
| 
120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
122
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub simple_compare {  | 
| 
123
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self            = shift;  | 
| 
124
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $a               = shift;  | 
| 
125
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $b               = shift;  | 
| 
126
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $similar_percent = shift;  | 
| 
127
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $crop_percent    = shift;  | 
| 
128
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
129
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $sa = $self->simplify($a);  | 
| 
130
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $sb = $self->simplify($b);  | 
| 
131
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $sa eq $sb ) {  | 
| 
132
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         return 1;  | 
| 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
134
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
135
 | 
0
 | 
  
  0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
     return unless ( $similar_percent || $crop_percent );  | 
| 
136
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
137
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $la  = length($sa);  | 
| 
138
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $lb  = length($sb);  | 
| 
139
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $max = ( $la < $lb ) ? $lb : $la;  | 
| 
140
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $min = ( $la < $lb ) ? $la : $lb;  | 
| 
141
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
142
 | 
0
 | 
  
  0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
     return unless ( $min and $max );  | 
| 
143
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
144
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $dist = undef;  | 
| 
145
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $self->options->{LevenshteinXS} ) {  | 
| 
 
 | 
 
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
146
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $dist = Text::LevenshteinXS::distance( $sa, $sb );  | 
| 
147
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
148
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     elsif ( $self->options->{Levenshtein} ) {  | 
| 
149
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $dist = Text::Levenshtein::distance( $sa, $sb );  | 
| 
150
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
151
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     unless ($crop_percent) {  | 
| 
152
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $crop_percent = $similar_percent * ( 2 / 3 );  | 
| 
153
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
155
 | 
0
 | 
  
  0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
     if ( ( defined $dist ) && ( ( ( $min - $dist ) / $min ) >= $similar_percent ) ) {  | 
| 
156
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         return -1;  | 
| 
157
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
158
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
159
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $min < 10 ) {  | 
| 
160
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         return 0;  | 
| 
161
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
162
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( ( ( ( 2 * $min ) - $max ) / $min ) <= $crop_percent ) {  | 
| 
163
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         return 0;  | 
| 
164
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
165
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( substr( $sa, 0, $min ) eq substr( $sb, 0, $min ) ) {  | 
| 
166
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         return -1;  | 
| 
167
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
168
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return 0;  | 
| 
169
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
170
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
171
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub status {  | 
| 
172
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
173
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $self->info->status( ref($self), @_ );  | 
| 
174
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	return;  | 
| 
175
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
176
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
177
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub error {  | 
| 
178
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
179
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     carp( ref($self), " ", @_ );  | 
| 
180
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	return;  | 
| 
181
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
182
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
183
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub changed {  | 
| 
184
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
185
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $self->info->changed(@_);  | 
| 
186
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
187
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
188
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub wav_out {  | 
| 
189
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
190
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $fh   = shift;  | 
| 
191
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( $self->options->{wav_out_system} ) {  | 
| 
192
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         my @sys = ();  | 
| 
193
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         foreach ( @{ $self->options->{wav_out_system} } ) {  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
194
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             my $a = $_;  | 
| 
195
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $a =~ s/\[FILENAME\]/$self->info->get_data('filename')/ge;  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
196
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             push @sys, $a;  | 
| 
197
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
198
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $self->status( 0, "Executing ", join( " ", @sys ) );  | 
| 
199
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		my $in;  | 
| 
200
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         if ( open( $in, '-|', @sys ) ) {  | 
| 
201
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             binmode $in;  | 
| 
202
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             binmode $fh;  | 
| 
203
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             my $buffer = "";  | 
| 
204
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             while ( my $count = sysread( $in, $buffer, 1024 ) ) {  | 
| 
205
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 my $wrote = 0;  | 
| 
206
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 while ( $wrote < $count ) {  | 
| 
207
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     $wrote += syswrite( $fh, $buffer, ( $count - $wrote ), $wrote );  | 
| 
208
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
209
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 $buffer = "";  | 
| 
210
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
211
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             return 1;  | 
| 
212
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
213
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		CORE::close($in);  | 
| 
214
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         return 0;  | 
| 
215
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
216
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return;  | 
| 
217
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
218
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
219
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub options {  | 
| 
220
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
     my $self = shift;  | 
| 
221
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     unless ( exists $self->{_options} ) {  | 
| 
222
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         $self->{_options} = Config::Options->new( $self->default_options );  | 
| 
223
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
224
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return $self->{_options}->options(@_);  | 
| 
225
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
226
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
227
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
 sub default_options { return {} }  | 
| 
228
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
229
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub DESTROY {  | 
| 
230
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
 
 | 
 
 | 
     my $self = shift;  | 
| 
231
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     if ( exists $self->{info} ) {  | 
| 
232
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		delete $self->{info};  | 
| 
233
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
234
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	return;  | 
| 
235
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
236
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
237
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
238
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
239
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |