while () { if (/\[server(\d)\]/) { do { $throwaway = ; } until { $throwaway = /\[server(\d)\]/ }; } else { push @output, $_; } print OUT @output;