#!/usr/bin/perl -l use strict; use warnings; my $file; { local $/ = undef; $file = scalar ; } ## Find me two newlines or be the start of the file ## Followed by any amount of newlines ## Followed by one or more characters (our capture, your paragraph) ## Followed by any amount of newlines ## Followed by any two newlines or the end of the file ## Flags: treat the file as one line, continue search for more paragraphs (/g in list context) while ( $file =~ m/ (?>\n{2}|\A) \n* (.+?) \n* (?=\n{2}|\z)/sxg ) { print "

$1

"; } __DATA__ Paragraph one is this Paragraph two is this Paragraph three is this Paragraph three and this But stops here and doesn't get the rest of the newlines