#!/usr/bin/perl -w use strict; use CGI; my ($q, $artist, $title, $album, $file, $arti, $albu, $tite, $track, $path, $results); $file = "/Library/Webserver/Documents/mp3.info"; $q = new CGI; $artist = $q->param( "artist" ); $album = $q->param( "album" ); $title = $q->param( "title" ); if ( length($artist) > 20 or length($title) > 20 or length($album) > 20) { display_page( "I am sorry but the was a malformed query" ); exit; } open (FILE, $file) or die ("Can't open $file: $!\n"); while () { ($arti, $albu, $tite, $track, $path) = $_ =~ m/^(.*?)::(.*?)::(.*?)::(.*?)::(.+?)$/; if ($arti =~ /*+?$artist*+?/i or $tite =~ /*+?$title*+?/i or $albu =~ /*+?$album*+?/i) { $results .= $q->li( $q->a( { href => $path }, "$artist - $title") ); } } close (FILE); print $q->header, $q->start_html, $q->h1("Results for $artist :: $title"), $q->ul( $results || "No results found" ), $q->end_html; sub display_page { my $message = shift; print $q->header, $q->start_html, $q->p( $message ), $q->end_html; }