If you want to find which lines match a pattern you an use
grep and if you want to print all them out you can use something like:
print join('', grep(/whatever/, @lines));
If you just want to print out the first match you can use
print ((grep(/whatever/, @lines))[0]);