#!/usr/bin/perl use strict; use warnings; # --- HERE document construct my $page = < [snip some html] Your title

Hello, world!

[snip some html] END_OF_HTML print $page; print "=" x 50; sub body_generate { my $tmp; $tmp = "

Subroutines or functions can be called too!

"; return $tmp; } my $subject = "Test for embedding variables in here document"; my $page2 = <$subject @{ [ body_generate ] }

For details see 'Perl Cookbook', recipe 1.10 "Interpolating functions and expressions within strings.

END_OF_HTML print $page2;