#creates web pages from AIC use strict; my $header="\n".''."\n"; my $footer="\n
Back to TOC\n\n\n\n"; my $dbin='the audiofile internet companion output file'; my $dboutdir='the dir to drop the web into'; my %TOC; my $key; open IN, "<$dbin" or die "Cannot open $dbin :$!"; print "Creating album files...\n"; while(){ my @details=split /"/; my @codearray=split /\/, $details[1]; my $code=$codearray[1]; my $totaltime=$codearray[$#codearray]; my $minutes=int ($totaltime/60); my $seconds = $totaltime-($minutes*60)-2; my @timesarray=split /\/, $details[3]; my $unknown1=$details[4]; my $title=$details[5]; my $artist=$details[7]; my $artist2=$artist; if ($artist=~/^the /i){ $artist2=~s/^The //i; $artist2="$artist2, The"; } my $filename=lc($artist2.$title.".htm"); $filename=~s/[\?\\\/:\*"'<>\| ]//g; my @songsarray=split /\/, $details[9]; my $songlink="$title"; my $genre=$details[11]; # Write the output HTML file if (!-e "$dboutdir/$filename"){ open OUT, ">$dboutdir/$filename" or die "Cannot open $dboutdir/$filename for write :$!"; print OUT "$header
"; print OUT "

$artist
$title

"; print OUT "\n"; #write out the song titles for (0..$#songsarray) { print OUT "\n\n"; print OUT "\n"; print OUT "\n"; } print OUT ""; printf OUT ("",$minutes,$seconds); print OUT "
",$_+1,".$songsarray[$_]$timesarray[$_]
--------
%02d:%02d
\n"; print OUT "$footer"; close OUT; } $TOC{$filename}="$artist2 $songlink";#add Genre Here } close IN; ######################################### print "Writing Table of contents file...\n"; open TOCFILE, ">$dboutdir/TOC.htm" or die "Cannot open $dboutdir/TOC.htm for write :$!"; print TOCFILE "$header\n"; print TOCFILE "

0to9 "; for('a'..'z'){ print TOCFILE "$_ "; } print TOCFILE "All"; print TOCFILE "

".(keys %TOC)." Albums

"; print TOCFILE "

Generated via Perl script on
".scalar localtime()."

"; close TOCFILE; ######################################### print "Printing Alphabetical Sort...\n"; for ('a'..'z'){ open LETTERFILE, ">$dboutdir/$_.htm" or die "Cannot open $dboutdir/$_.htm for write :$!"; print LETTERFILE "$header"; print LETTERFILE "

$_

"; foreach $key (sort keys %TOC){ if($key=~/^$_/){ print LETTERFILE "$TOC{$key}
\n"; } } print LETTERFILE "$footer"; close LETTERFILE; } ###################################### open ALLFILE, ">$dboutdir/all.htm" or die "Cannot open $dboutdir/all.htm for write :$!"; open NUMFILE, ">$dboutdir/0to9.htm" or die "Cannot open $dboutdir/0to9.htm for write :$!"; print ALLFILE $header; print NUMFILE $header; print ALLFILE "

All

\n"; print NUMFILE "

0to9

\n"; foreach $key (sort keys %TOC){ if ($key=~/^\d/){ print NUMFILE "$TOC{$key}
\n"; } print ALLFILE "$TOC{$key}
\n"; } print ALLFILE "$footer"; print NUMFILE "$footer"; close ALLFILE; close NUMFILE;