Solved

How to print html

Posted on 2009-05-07
3
143 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 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video discusses moving either the default database or any database to a new volume.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now