!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $file = 'test.txt'; { open my $fh, '<', $file or die "$file: $!"; # change block separator to have one complete frame # read per iteration local $/ = "\nFRAME NAME:"; # read the blocks while ( my $frame = <$fh> ) { next if $. == 1; # skip the "header" chomp $frame; # remove block separator # print the frame print "This is a frame:\n", '=' x 30, "\n", $frame, "\n", '=' x 30; } close $fh; }