About this tool
Convert HTML to Perl CGI output and convert Perl or VPerl-style templates back into clean HTML placeholders.
The HTML Perl Converter moves markup between plain HTML and Perl CGI in both directions: HTML to Perl wraps your markup in a heredoc printed after a CGI header, turning every {{ placeholder }} into a declared Perl scalar, and Perl to HTML pulls the heredoc body back out, strips the shebang and use strict/CGI boilerplate, and rewrites $scalars and <%= %> VPerl tags back into {{ placeholder }} form. It is aimed at anyone maintaining legacy CGI scripts who wants to edit the markup in a normal HTML editor instead of inside quoted Perl. Logic blocks like <% if ... %> are preserved as HTML comments rather than silently dropped, so nothing disappears without a trace.
Open HTML Perl Converter on AltFTool — it loads instantly in your browser.
Choose HTML to Perl or Perl to HTML, then paste into Source code, press Upload code for a .html, .pl, .cgi or .pm file, or press Load sample.
Toggle the conversion options — Add shebang, Strict + warnings, CGI header and Placeholders to scalars going out, or Strip boilerplate and VPerl expressions coming back.
Read the converted output with its warnings about unescaped dollar signs, then Copy it or Download converted.cgi or converted.html.
If the word HTML already appears alone on a line in your markup, the terminator becomes HTML_BLOCK so the heredoc cannot close early.
Each distinct {{ key }} produces one my $key = '...'; line with a readable default, so the generated script runs instead of erroring on undefined scalars.
Non-expression <% ... %> blocks come back as <!-- Perl logic removed: ... --> and are counted in the warnings, so you know exactly what still needs rewriting.
It uses a double-quoted heredoc: print <<"HTML"; followed by your markup and a closing HTML line. Double quotes are deliberate, because that is what allows $scalar interpolation inside the block; if the terminator word already exists on its own line in your markup, the tool switches to HTML_BLOCK to avoid closing the block early.
Because a double-quoted heredoc interpolates them. Perl will try to read $foo inside your markup as a variable, so any literal dollar sign — a jQuery $, a price, a regex — has to be escaped as \$ or the output will be wrong. The tool raises this warning whenever it finds a $ in HTML that contained no placeholders.
No, and that is intentional. Expression tags <%= $name %> map cleanly to {{ name }}, but control flow such as <% foreach %> or <% if %> has no HTML equivalent, so each block is turned into an HTML comment recording the original code and counted in the warnings for you to port by hand.
The shebang line, use strict; and use warnings;, the use CGI qw(...) import, print header(...) and any raw print "Content-Type: ..." line. When a heredoc is found, its body is used directly instead — the surrounding script is simply not carried over.
Add the HTML Perl Converter widget to your blog or website — free, responsive, no signup. Just keep the “Widget by AltFTool” credit link visible.
<iframe src="https://www.altftool.com/embed/widget/html-perl-converter"
title="HTML Perl Converter — free AltFTool widget"
width="100%" height="640" style="border:0;border-radius:12px;overflow:hidden"
loading="lazy" referrerpolicy="no-referrer-when-downgrade" allow="clipboard-write"></iframe>
<p style="font-size:12px;margin:4px 0 0">Widget by <a href="https://www.altftool.com/tools/all/html-perl-converter?utm_source=embed&utm_medium=widget" rel="nofollow">AltFTool — free online tools</a></p>