X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FApp%2FMusicExpo.pm;h=7b5f4e2f46d7ba70d0bcb3b7852f03d1b81afb9c;hb=1549062d92de87827a1e0016c898145f5a47eb63;hp=ee8a8f54b64d9613a5cf785a4b0037574d2ba774;hpb=b67c2762b65efca590eb4d7c6eab9b8578d1e821;p=app-musicexpo.git diff --git a/lib/App/MusicExpo.pm b/lib/App/MusicExpo.pm index ee8a8f5..7b5f4e2 100644 --- a/lib/App/MusicExpo.pm +++ b/lib/App/MusicExpo.pm @@ -98,17 +98,17 @@ sub normalizer{ } sub run { - tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644 unless $cache eq ''; - memoize 'flacinfo', NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] unless $cache eq ''; - memoize 'mp3info' , NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] unless $cache eq ''; - memoize 'vorbisinfo' , NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] unless $cache eq ''; + if ($cache) { + tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644; + memoize $_, NORMALIZER => \&normalizer, LIST_CACHE => 'MERGE', SCALAR_CACHE => [HASH => \%cache] for qw/flacinfo mp3info vorbisinfo/; + } my %files; for my $file (@ARGV) { my $info; - $info = thaw flacinfo $file if $file =~ /.flac$/i; - $info = thaw mp3info $file if $file =~ /.mp3$/i; - $info = thaw vorbisinfo $file if $file =~ /.og(?:g|a)$/i; + $info = thaw flacinfo $file if $file =~ /\.flac$/i; + $info = thaw mp3info $file if $file =~ /\.mp3$/i; + $info = thaw vorbisinfo $file if $file =~ /\.og(?:g|a)$/i; next unless defined $info; my $basename = fileparse $file, '.flac', '.mp3', '.ogg', '.oga'; $files{$basename} //= [];