in reply to new line every match

You have a record separator: "address", it's just disguised as a record heading. Perl knows how to deal with alternate record separators (alternate to "\n", that is), as long as they can be represented as a literal string.

local $/ = q{address}; # Set record separator to 'address'. open my $infile, '<', 'filename.txt' or die $!; print "This is the list of addresses\n", "here are the addresses\n"; while( <$infile> ) { chomp; # chomp removes the trailing record separato +r. s/^\s+|\s+$//g; next unless length; print "address $_\n"; }

Dave