Like others have said, you can't ref the DATA block in the BEGIN section. And a HEREDOC isn't a bad solution, but if you'd like to better seperate the logic from the code and have it in your BEGIN section, you could use a do to a seperate file that has the HEREDOC in it. This might lead to a bit of a cleaner design.