<%mc_comp('Template',top=>1)%>

<b>Searching by <%$mode%></b><P>

% if ($mode eq "artist" && scalar @found > 0) {
% foreach my $artist (@found) {
% my $artistlink = $artist;
% $artistlink =~ s/ /_/g;
<a href="artist?artist=<%$artistlink%>"><%$artist%></a><br>
% }
% } elsif ($mode eq "title" && scalar @found > 0) {
<table border=1><tr><th>Artist</th><th>Title</th><th>Price</th></tr>
% foreach my $id (@found) {
<%mc_comp('tools/cd_details',id=>$id,cds=>\%cds,table=>1)%>
% }
</table>
% } else {
<em>Sorry, but no results were found</em><p>
% }
<%mc_comp('Template',bottom=>1)%>

<%PERL_INIT>
my (@found);
my %cds = %{mc_comp('data/cds')};
my %artists = %{mc_comp('data/artists')};
if ($mode eq "title") {
   while (my ($id,$rec) = each %cds) {
      push @found,$id if $rec->{title}=~/$sstring/;
   }
} elsif ($mode eq "artist") {
  @found = grep /$sstring/, keys %artists;
} else {

}
</%PERL_INIT>

<%PERL_ARGS>
$sstring=>undef
$genre=>undef
$mode=>undef
</%PERL_ARGS>

