[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to print html

Posted on 2009-05-07
3
Medium Priority
?
152 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
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 85

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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
Suggested Courses

834 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