in reply to nesting loops help?

Does the inner loop even make sense? You'll just end up printing the same line over and over again. Don't you want

while (<$search_file>) { print $wave $_ if /$regex/ && !/SCRIPTNAME|DESCRIPTION/; }

As for the new requirement, Is there any way you can build a hash or regex pattern from it?