#!/usr/bin/perl ######################################## # A. I. D. v1.0 # # database search script # # coded by bitsmart # # (c) 2007 Andrew Prentice # # bitsmart0@gmail.com # ######################################## print "\nThis program searches for songs with the same BPM.\n"; print "\nWhat BPM do you want to search for? "; chomp($inpt = ); #get the BPM to search for print "searching..."; #make it look like we're doing something $bpm = "BPM=$inpt"; #add our little tag opendir(DIREC,".") || die "cannot open directory"; #open current directory w/ error handling foreach $name(sort(readdir(DIREC))) { #for each filename beginning w/ "BPM-", add to array if ($name =~ /^BPM-/) { #if the name contains "BPM-"... push @files, $name; #add it! } print "."; #add another "doing something" mark } closedir(DIREC); #close the dir foreach my $filename ( @files ) { #for each filename in the array open(PHILE, '<', $filename) || die "cannot open $filename: $!"; #open file w/ error handling my @lines = scalar ; #get the Artist/Album info while ( ) { push @lines, $_ if /$bpm/; } if ( @lines > 1 ) { print @lines; } else { print "sorry, no matching BPMs found."; #deliver the bad news } close PHILE; #finish up }