#! /usr/bin/perl sub read_blocks { my $handle = shift; local $/ = shift; while ( my $block = <$handle> ) { # replace newlines with simple space $block =~ tr/\r\n/ /s; print ">>> $block <<<\n"; } } # give it a handle, and the block delimiter read_blocks( *DATA, "....\n" ); __DATA__ la le lu .... foo bar .... what ever ....