in reply to Condition on multiple lines and big file
And, for simpler situations of the same basic problem, also consider awk. This is the original tool from which, in one sense, the earliest Perl interpreters grew. It's still great for text-file munging.