Your own Perl code displays itself with colored tags on a web page! Best if the entire web page is a CGI.
# display this Perl CGI code! open (HIN,"code.pl") or die "Unable to read $0 file: $!\n"; @code=<HIN>; close (HIN); foreach (@code) { # prevent html code from activating s/&/&amp;/g unless /\x26\x26/; s/</&lt;/g; # colorize comments in the code s@#(.*)$@<span style="color:green;">#$1</span>@g if /#\s/&&!/#\(/; # colorize certain Perl keywords s@^#!(.+)@#<span style="color:purple;">!$1</span>@; s@(\s*print\s*|elsif|eq\s|ne\s|foreach|while|open\s|close\s|if\s|use\s +|die\s|\sor\s)@<span style="color:red;">$1</span>@ig unless /\(print/ +; s@(\x26\x26\s|\x2d>|\x3d>|\x2e=|\x7c\x7c\s|\x3a\x3a|\x2d\x2d|\x2b\x2 +b)@<span style="color:#CC33FF;">$1</span>@g;# && -> => .= || :: -- ++ # colorize variables s@([\$\@]\w+)@<span style="color:blue;">$1</span>@g; # vars s@([\$\@][!_|])@<span style="color:blue;">$1</span>@g; # $! $_ $| @! + @_ @| # add this changed code to the stream $purl.=$_; } print "<font size=-1><pre>$purl</pre></font>"; # end

In reply to Code on web in color! by mushu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.