in reply to Look for pattern in file. ????

On each trip around the while( <INPUT> ) loop, you do:

my $pattern = pop @lines;

Which leaves @lines empty. But you never refill it for the next trip around the while( <INPUT> ) loop.

Also see quotemeta if you want to do literal matches and match dot as dot instead of a wildcard.