building an array of hashes from MP3::Info

S

shambolic

Hi,

a few newby questions on building more complex data structures, if
that's ok.

i want to find duplicate mp3 files on my hardrive based on near
matches for track title (TITLE) and Filename using MP3::Info.

i have array @mp3s, of all the mp3 files on my drive, and looping
through that get a hash of mp3 tags for each file (%hash). i then push
%hash into an array, which i can loop through to compare duplicates,
etc.


so something along the lines of:

use warnings;
use strict;
use MP3::Info;

# == snip: build @mp3s using File::Find ==

for my $file(@mp3s) {
next unless /mp3/;

# create hash with tag metadata
print "trying to get tag for:$file\n\n";
my $tag = get_mp3tag("$file") or die "no TAG info: $!";
my %hash= %$tag;

# create array of hashes
push my @files, {%hash};

# loop through array of hashes

for my $i (0 ..$#files) {
for my $element (keys %{ $files[$i] } ) {

# insert find duplicate code here.

print "$element is $files[$i]{$element}\n";
}
}

so my questions are:
* are there any modules that would do this better?
* is it better to use an array of hashes or a hash of hashes (i've
found it easier to use the array)?
* what is the best way to match approximate values for filenames and
TITLES? maybe String::Approx?
* any other tricks i've (probably) missed with respect to design or
approach?

many thanks in advance

j
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top