[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to print html

Posted on 2009-05-07
3
Medium Priority
?
151 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 600 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 150 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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

649 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