#!/usr/local/bin/perl -w #usage: c2html.pl myprog.c ($infilename)=@ARGV; #get infilename from command line open IN,"<$infilename" or die "cannot open $infilename"; @all=; #put lines of IN into an array if ($infilename=~m/\.c$/){ #check for .c at end of filename print "conversion of $infilename to html
\n"; $left=q!/*!; #string between the ! will be used below $right=q!*/!; #string between the ! will be used below for $line (@all){ $line=~s//>/;# > is special in html, sub > $line=~s+/\*+$left+; # turn on blue color at start of comments $line=~s+\*/+$right+; # turn off blue color at end of comments } } else { # cannot do anything except for .c die "cannot convert $infilename \n"; } #print out preformatted html with blue comments print "
@all
";