# this is short but memory intensive do_stuff() if grep { /something/ } @array # compared to this which is faster and uses less memory # but takes 4 lines to write instead of one.... for(@array) { next unless /something/; do_stuff(); last; }