#!/usr/bin/perl $copy = 0; $name = shift; while (<>) { /SAT=/ and $sat = $_; /running time \[$name\]/ and do { print $sat; $copy = 1; }; $copy and /^-------------/ and last; print if $copy; }