#!/usr/bin/perl -w use strict; use warnings; my $code=<<"END_MSG"; line 1 line2 END_MSG sub foo{ return $code; } print "before calling\n"; print $code; print "after calling\n"; print foo();