Friday, November 4, 2011

HTML in Perl

bash$cat html.pl
#!/usr/bin/perl
#use CGI::Carp qw(fatalsToBrowser);
print "Content-type:text/html\n\n";
print <<'EndHTML';
<html>
<head>
<title>Fish Report</title>
</head>
<body>HTML Test message </body>
</html>
EndHTML


This print command tells the program to print the HTML code until it finds the word EndHTML again on its own. You can use any word or group of letters you like, just be sure you use the same thing when you want to end the HTML code. For instance, some people use EOM to do this.

print <<EOM;
....your HTML code here.....

EOM 


 To check if HTML syntax are ok :

# perl -c html4.pl
html.pl syntax OK











No comments:

Post a Comment