in reply to using split on a file

Haven't tested it but this should work

Using a filehandle (as you were with <FILE>) only returns a line at a time.

my ($allsource) ; while <FILE> { $allsource .= $_ ; } # Now $allsource contains all of the lines of the file my (@segments) = split /%{5}/, $allsource ; # Each element in @segments is one of the segments # Could undefine $allsource to free a little memory undef ($allsource) ;