#!/usr/bin/perl # # dbmusic.pl v0.0.18 - Database for music albums # Copyright (C) 2005, 2006, 2009, 2011 Stian Skjæveland # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # use CGI qw(:standard); use strict; print header; print qq(
|
|
|
); &display_search(); print qq( Music database - Results: ); my $param_search=lc(param('search')); my $param_alt=lc(param('alt')); my $file="/home/stunix/domains/atlantiscrew.net/public_html/stian/doc/list.txt"; # You may set this to whatever fits your system. my ($bandname, $albumtitle, $yearofrelease, $genre, $other, $i, $calc, $filelength, @filelines); my $found=0; my $count=0; open(DB_FILE, "<$file") || print "Cannot find file: $file ";
@filelines= ";
if ($param_alt) {
&view_db();
}
close(DB_FILE);
sub view_db() {
print qq(
);
if ($found ne 1) {
print " No match. Try different keyword(s).";
} else {
$filelength=@filelines;
print " $count match(es) of total $filelength";
$calc=$count * 100 / $filelength;
print " ($calc\%).";
}
sub view_db_results() {
($bandname, $albumtitle, $yearofrelease, $genre, $other)=split('@', $filelines[$i]);
print " |