First off I would recommend doing this to get all the text (in my opinion) if you dont' have a large file anyways:
open(FILE, "<", "numb.txt" ) || die "Unable to open numb.txt <$!>\n";
@inputFile = <FILE>;
foreach $line (@inputFile)
{
}
What that is doing is opening the file, then sticking each line in the @inputFile array, from there you are going to "loop" through using a for loop,
Now simply set your requirements (if then statement) for the particular line, I suppose you could simply do a "double for loop", as in stick a for loop inside, that for loop and do a compare of $line with whatever other "line" you call, and if they match then you can simply set a flag to print it to the output file,
Don't forget to print to your output file you would need to add FILE to your print statement:
print FILE "whatever your wanting to print";
If that doesn't help just let me know,
I have a few posts (older) on my blog with a couple perl examples, but you can use that code to look at how to get the lines out of a file if you want as well....
onaclov2000.blogspot.com
Then again I might be completely missing the point of your post....