Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > building an array of hashes from MP3::Info

Reply
Thread Tools

building an array of hashes from MP3::Info

 
 
shambolic
Guest
Posts: n/a
 
      02-21-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array of Hashes in an array of hashes - Complicated! Matt Brooks Ruby 16 09-16-2009 05:53 PM
How to make an array of hashes to a single array with all thevalues of these hashes ? kazaam Ruby 12 09-13-2007 01:30 PM
Hash of hashes, of hashes, of arrays of hashes Tim O'Donovan Perl Misc 5 10-28-2005 05:59 AM
Help Needed Building Array Of Hashes From CSV Tim Sheets Perl Misc 15 05-08-2004 12:55 AM
Hashes of Hashes via subs Ben Holness Perl 8 10-08-2003 06:57 AM



Advertisments