#!/usr/bin/perl use strict; use warnings; my $text = do { local $/; #slurp ; }; my @comments = $text =~ /(?<====Comments===).*?(?==|$)/gs; my @additional = $text =~ /(?<==Aditional Notes=).*?(?==|$)/gs; 1; __DATA__ ===Comments=== This webpage contains information bla bla bla =Section 2= Some more text here. ===Comments=== Some other comments here. =Another section= =Aditional Notes= More notes here.