#!/usr/bin/perl
my $mp3=shift;
chomp $mp3;
-f $mp3 or die;

my $cmd="/usr/bin/id3 -l $mp3";
my @result=`$cmd`;

#while my $res (@result) {
while my $res (DATA) {
    chomp $res;
    $mp3s{$mp3}{title}=$res if $res=~/Title  :/;
    $mp3s{$mp3}{artist}=$res if $res=~/Artist :/;
    $mp3s{$mp3}{album}=$res if $res=~/Album  :/;
    $mp3s{$mp3}{year}=$res if $res=~/Year :/;
    $mp3s{$mp3}{comment}=$res if $res=~/Comment :/;
    $mp3s{$mp3}{genre}=$res if $res=~/Genre :/;
    $mp3s{$mp3}{track}=$res if $res=~/Track :/;
}

foreach my $mp3 (keys %mp3s) {
    $mp3s{$mp3}{title}, 
    $mp3s{$mp3}{artist},
    $mp3s{$mp3}{album},
    $mp3s{$mp3}{year},
    $mp3s{$mp3}{comment},
    $mp3s{$mp3}{genre},
    $mp3s{$mp3}{track},
}

sub insert_into_db {
    my $mp3_href=$_[0];
__DATA__
Title  : 12_Figment                      Artist: Enemy of the Good             
Album  : 06Oct2012                       Year: 2012, Genre: Cult (58)
Comment: Peter, Chloe, SD                Track: 12
