in reply to Regular expressions

You could also use File::Slurp. Not sure if it's advantageous speed or algorithmwise; the documentation claims it does. But I just like it for readability.