print "foo = $foo \n"; <<'END_COMMENT'; And then we print $foo. By the way, make sure you use single quotes for this here document otherwise your @variables will wind up being interpolated. Except you shouldn't use this in the first place, so the point is moot. END_COMMENT