http://www.perlmonks.org?node_id=1098797


in reply to RFC Using PERL HEREDOC script within bash

Other solutions here