use strict;
use warnings;
-our $VERSION = '0.003002';
+our $VERSION = '0.003003';
use Audio::FLAC::Header qw//;
use HTML::Template::Compiled qw//;
use File::Basename qw/fileparse/;
use Fcntl qw/O_RDWR O_CREAT/;
use Getopt::Long;
-use JSON;
+use JSON::MaybeXS;
use Storable qw/thaw freeze/;
##################################################
}
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) {
push @files, \%entry
}
- my $json = JSON->new->utf8->canonical->encode({files => \@files, prefix => $prefix});
+ my $json = JSON::MaybeXS->new(canonical => 1)->encode({files => \@files, prefix => $prefix});
$json =~ s/</</g;
$json =~ s/>/>/g;
$ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files], prefix => $prefix, json => $json);