Perl script for code formatting
print "<pre><code>\n";
while(<>)
{
s/</</g;
s/>/>/g;
print $_;
}
print "</pre></code>\n";One thing that is pretty cool is I used the script to escape itself. I called the script cppwebify.pl so the command line I used on a Win32 machine was
perl cppwebify.pl cppwebify.pl > output.html
I redirected the output from the script to the file output.html. I had to change the output to have the ampersand character by the way. I thought someone would be inspired by this to make a truly useful script for the cpp community to use for posting code. I wanted to use Javascript to do the formatting so you didn't have to have Perl but my Javascript is so rusty I couldn't do it without the book that I've left at school. My idea was to have webpage were you could paste cpp code into a text box then push a button to escape it for you, then you could copy and paste the escaped code to where you are writing a post. Maybe when I get a hold of my Javascript book I'll get it done.
