while (<>) { push(@array, $_) if /one/ .. /two/; do_something() if /two/; }