#!/usr/bin/perl use strict; use warnings; sub foo { my $code = shift; return <<"END_MSG"; Add the code <$code> END_MSG } my $code = <<'END_MSG'; line 1 line2 END_MSG print "before calling\n"; print $code; print "after calling\n"; print foo($code); print "why blank line above?\n"; #### sub foo { my $code = shift; chomp $code; return <<"END_MSG"; Add the code $code END_MSG }