while (<$output>) { next if (m/^$/); last if (m/^Press.*/) #grab bits here instead of using awk }