) {
my $band = "";
my $title = "";
if ($line =~ m@Current Mood / Music : (?:[^\\/]+) / ([^\\-]+) - "([^\\"]+)"@) {
$band = $1; $title = $2;
}
else {
if ($line =~ m/Music : ([^\\-]+) - "([^\\"]+)"/) {
if ($1 ne "\$band_name" && $2 ne "\$song_name") {
$band = $1; $title = $2;
}
}
}
if ($band ne "" && $title ne "") {
$band = "Bad Religion" if ($band eq "BR");
$band = "Less Than Jake" if ($band eq "LTJ");
$band = "No Use For A Name" if ($band eq "NUFAN");
$band = "Reel Big Fish" if ($band eq "RBF");
$band = "Red Hot Chilli Peppers" if ($band eq "RHCP");
push(@music_list, {"Band"=>"$band", "Title"=>"$title", "TitleOccurance"=>0, "BandOccurance"=>0});
if ( !exists($band_count{"$band"}) ) {
$band_count{"$band"} = 1;
}
else {
$band_count{"$band"} += 1;
}
if ( !exists($band_count{"$band" ."_" . "$title"}) ) {
$band_count{"$band" ."_" . "$title"} = 1;
}
else {
$band_count{"$band" ."_" . "$title"} += 1;
}
}
}
close (IN) || die("Cannot close $in_filename: $!\n");
}
for (my $j = 0; $j <= $#music_list; $j++) {
$music_list[$j]{"BandOccurance"} = $band_count{$music_list[$j]{"Band"}};
$music_list[$j]{"TitleOccurance"} = $band_count{$music_list[$j]{"Band"} . "_" . $music_list[$j]{"Title"}};
}
foreach my $out_filename ( ("mh.html", "mh.xml") )
{
open (OUT, ">$out_filename") || die("Cannot open $out_filename for writing: $!...\n");
@music_list = sort by_title_occurance (@music_list);
if ($out_filename eq "mh.html") {
print OUT "\n";
print OUT "\n";
print OUT "\n\n\tMusic habits\n\n";
print OUT "\n\n";
print OUT "My music habits...
\n";
print OUT "This file is generated by reading my news pages and gathering what songs I've been listening to...
\n";
print OUT "It then takes that information and sorts it and based on how much I've told people I'm listening to something,
\n";
print OUT "that's how much I must like it...
\n";
print OUT "
\n\n";
print OUT "My favorite song(s) must be:
\n";
} else {
print OUT "\n";
print OUT "\n";
print OUT "\n";
}
if ($out_filename eq "mh.html") {
} else {
print OUT "\n";
}
for (my $j = 0; $j <= $#music_list; $j++) {
if (($music_list[$j]{"TitleOccurance"} == $music_list[0]{"TitleOccurance"})
&& ($j == 0 || $music_list[$j]{"Title"}) ne $music_list[$j - 1]{"Title"}) {
my $band = html_escape($music_list[$j]{"Band"});
my $title = html_escape($music_list[$j]{"Title"});
if ($out_filename eq "mh.html") {
print OUT "'$band' - '$title'
\n";
}
else {
print OUT "\n";
}
}
}
if ($out_filename eq "mh.html") {
} else {
print OUT "\n";
}
@music_list = sort by_band_occurance (@music_list);
if ($out_filename eq "mh.html") {
print OUT "
\n\n";
print OUT "My favorite band(s) must be:
\n";
}
if ($out_filename eq "mh.html") {
} else {
print OUT "\n";
}
for (my $j = 0; $j <= $#music_list; $j++) {
if (($music_list[$j]{"BandOccurance"} == $music_list[0]{"BandOccurance"})
&& ($j == 0 || $music_list[$j]{"Band"}) ne $music_list[$j - 1]{"Band"}) {
my $band = html_escape($music_list[$j]{"Band"});
if ($out_filename eq "mh.html") {
print OUT "$band
\n";
}
else {
print OUT "\n";
}
}
}
if ($out_filename eq "mh.html") {
} else {
print OUT "\n";
}
if ($out_filename eq "mh.html") {
print OUT "
\n\n";
print OUT "Song listing alphabetically by favourite bands:
\n";
}
for (my $j = 0; $j <= $#music_list; $j++) {
my $band = html_escape($music_list[$j]{"Band"});
my $title = html_escape($music_list[$j]{"Title"});
if ($out_filename eq "mh.html") {
print OUT "$band - $title
\n";
}
else {
print OUT "\n";
}
}
if ($out_filename eq "mh.html") {
print OUT "\n
By Flikky!\n\n";
print OUT "\n";
print OUT "\n";
}
else {
print OUT "\n";
}
close (OUT) || die("Cannot close $out_filename: $!\n");
}
}