print $data;; #some "random stuff" @include "some file" did you parse that? #more 'random' stuff @include 'another file' you sure? #and more random stuff @include yet\ another\ file positive? print for $data =~ m[\@include\s('[^']+'|"[^"]+"|.+?(?## m[ \@include \s ## the introducer followed by a space ( ## capture '[^']+' ## A single quoted string with no embedded single quotes | ## or "[^"]+" ## a double quoted string with no embedded double quotes | ## or .+? (?