#!/usr/bin/env perl use strict; use warnings; use autodie; my $file = 'pm_1226079_input.txt'; my $SEP = '-' x 40 . "\n"; open my $fh, '<', $file; { local $/ = "\n******************* NRG location"; while (<$fh>) { chomp; /parameters after change .+?\n(.*)\z/ms && print "$SEP$1\n"; } }