in reply to How To Use Bootstrap Code in Perl Script?
#!/usr/bin/perl use strict; use warnings; # --- HERE document construct my $page = <<END_OF_HTML ; <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> [snip some html] <title>Your title</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> </head> <body> <h1>Hello, world!</h1> [snip some html] <script src="js/bootstrap.min.js"></script> </body> </html> END_OF_HTML print $page; print "=" x 50; sub body_generate { my $tmp; $tmp = "<h1>Subroutines or functions can be called too!</h1>"; return $tmp; } my $subject = "Test for embedding variables in here document"; my $page2 = <<END_OF_HTML; <title>$subject</title> <body> @{ [ body_generate ] } <p>For details see 'Perl Cookbook', recipe 1.10 "Interpolating functio +ns and expressions within strings. </p> </body> END_OF_HTML print $page2;
See http://www.stonehenge.com/merlyn/UnixReview/col12.html for what happens is you use the different types of quotes around the here document marker (END_OF_HTML)
|
|---|