A low-tech solution would be to keep a (manually-updated) text file on your computer containing a list of all books currently in your bookshelf, and then adjust the Perl script to read that file and ignore search results from books not in that list. I'd use a command-line flag to tell the Perl script to use the file or return all results.