Solved

How to print html

Posted on 2009-05-07
3
149 Views
Last Modified: 2012-05-06
How would I print out embedded html in perl.  For example this works

print <<EOF;
<html>
<head>
<title>My HTML page</title>
</head>
<body>
<br>
First Message to print out
<br>
Second message to print out
<br>
Third message to print
</body>
</html>
EOF

however I want to add an if statement to determine which message to print out.   I tried the following with no luck

print <<EOF;
<html>
<head>
<title>My HTML page</title>
</head>
<body>
<br>
EOF

if($test == 0){
print <<EOF;
First Message to print out
<br>
EOF
}
else{
print <<HTML;
Second message to print out
<br>
HTML
}
print <<HTML;
</body>
</html>
HTML



0
Comment
Question by:warrior32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
FishMonger earned 200 total points
ID: 24328504
my $firstmsg = <<EOF;
First Message to print out
<br>
EOF

my $secondmsg = <<HTML;
Second message to print out
<br>
HTML

print $test == 0 ? $firstmsg : $secondmsg;
0
 
LVL 84

Expert Comment

by:ozo
ID: 24329327
There are other ways to do it, but what was unlucky about what you tried?
0
 
LVL 39

Assisted Solution

by:Adam314
Adam314 earned 50 total points
ID: 24329709
For this type of stuff, it is usually easier to use one of the HTML template modules.  Eithter HTML::Template or Template Toolkit:
    http://search.cpan.org/~samtregar/HTML-Template-2.9/Template.pm
    http://search.cpan.org/~abw/Template-Toolkit-2.20/lib/Template.pm
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question