This is my "final" PERL code:

#!/usr/bin/perl -w

$myFile = "/home/mydata/playlist.txt";

print "Content-Type: text/html\n\n";
print "<html><head><title>My Song List</title></head>\n";
print "<body>\n";


open(ALBUMS, "$myFile") or die "Can't open $myFile: $!\n";
while ($line = <ALBUMS>) {
	($song, $artist, $album, $location) = split('\|', $line);
	$songlist{$artist}->{$album} .= $song . "\+";
	$locations{$song} .= $location . "\+";
}

foreach $artist (sort keys %songlist) {
	print "<b>Artist:</b> ";
	
	if (!$artist) {
		print "\tNot Provided\n";
	} else {
		print "$artist\n";
	}
	
	foreach $album (sort keys %{$songlist{$artist}}) {
		print "<blockquote>\n";
		print "\t<b>Album:</b>";
		
		if (!$album) {
			print "\tNot Provided\n";
		} else {
			print "\t$album\n";
		}
		
		print "<blockquote>\n";
		print "\t\t<b>Songs:</b><br>\n";
		$i = 0;
		@songs = split('\+', $songlist{$artist}{$album});
		foreach $song (@songs) {
			@thislocation = split('\+', $locations{$song});
			foreach $location (@thislocation) {
				++$i;
				print "\t\t\t$i. <a href=\"http://$location\">$song</a><br>\n";
			}
		}
		print "</blockquote></blockquote>\n";
	}
}
Now, mind you that this is just a beginning, something to start on. I'm not sure if anybody else would do this the same way (probably not) but in this case it does a job. I'll throw later some search capabilities and off to fun we go!

P.S. What scares me the most is the fact that I haven't fully realized how I accomplished this task. I was playing with this code until I got it right. It's going to take some time before I feel comfortable with hashes, dereferencing and other "goodies." Meantime, I will enjoy what I have accomplished with you help! :-)


In reply to Re: Hashes hunt me even when I sleep.... by bman
in thread Hashes hunt me even when I sleep.... by bman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.