#!perl
use strict;
use XML::Simple;
#my $infile = '/home/zzz/Desktop/Scripting/usb/musicLibrary.txt';
#open IN,'<',$infile or die "Could not open $infile $!";
#while (<IN>){
my %hash=();
while (<DATA>){
chomp;
if (/\.m4a$/){
my @f = split '/',$_;
push @{ $hash{'artist'}{$f[-3]}{'album'}{$f[-2]}{'track'}},$f[-1];
}
}
open OUT,'>','report.xml' or die "$!";
print OUT XMLout(\%hash,RootName=>'records');
__DATA__
/Volumes/WD/Not Migrating/Music/Ana Tijoux
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Luchin
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Luchin/Luchin.m4a
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Intro.m4a
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Gol.m4a
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Track3.m4a
/Volumes/WD/Not Migrating/Music/Ana Tijoux/Kaos/Track4.m4a
Be aware of the STATUS of XML::Simple and the CAVEATS within
poj |