while () { print; if (/$pattern/) { &do_some_other_thing; } }