$kwd = qr/\b(absolute|and|array|asm|begin|break|case|const|constructor|continue|destructor|div|do|downto|else|end|file|for|function|goto|if|implementation|in|inherited|inline|interface|label|mod|nil|not|object|of|on|operator|or|packed|procedure|program|record|reintroduce|repeat|self|set|shl|shr|string|then|to|type|unit|until|uses|var|while|with|xor)\b/i; print "Pas2HTML converter 0.0.2 beta (c) Alexandr Ignatiev, 2007\n"; do{print 'File of Pascal program : '; chomp ($fname = ); } until ((open INF,($fname or die)) or not print("Can\'t read $fname!\n")); $fname=~/([^\\\/]*)$/;$fname=$1; print "File to produce : "; chomp($fn = ); $fn='program.htm' if $fn eq ''; open OUTF,">$fn"; print OUTF " $fname
";
while($_ = ){A:{
         if(/\G$kwd/cg){
                      print OUTF '',$1,''
         }elsif(/\G\'/gc){
	              print OUTF '\'';
                      STR:while(/\G(.)/gc){
                                if ($1 eq ' '){
                                    print OUTF ' '
                                }elsif($1 eq '<'){
                                    print OUTF '<'
                                }elsif($1 eq '>'){
                                    print OUTF '>'
                                }elsif($1 eq '"'){
                                    print OUTF '"'
                                }elsif($1 eq "'"){
                                    print OUTF '\'';last STR
                                }else{print OUTF $1}
                      };
         }elsif(/\G(\#\d+)/gc){
	              print OUTF '',$1,''
         }elsif(/\G\b(\d+(?:\.(?!\.)\d*\b)?|\$[a-zA-Z\d]*)/gc){
	              print OUTF '',$1,''
         }elsif(/\G\{/gc){
                       my $a='';
                       if (/\G\$/gc){
                          $a=1;print OUTF '{$'}
                       else{print OUTF '{'};
                       NEWCOMM:while(/\G([^\}])/gc){
                                if($1 eq '<'){
                                    print OUTF '<'
                                }elsif($1 eq '>'){
                                    print OUTF '>'
                                }elsif($1 eq '"'){
                                    print OUTF '"'
                                }else{print OUTF $1};
                                if (/\G\}/gc){
                                   print OUTF '}';
                                   last NEWCOMM
                                }elsif(/\G\Z/gc){last NEWCOMM
                                                      unless $_=;
                                                      print OUTF "\n"
                                };
                       };
         }elsif(/\G\(\*/gc){
                       my $a='';
                       if (/\G\$/gc){
                          $a=1;print OUTF '(*$'}
                       else{print OUTF '(*'};
                       OLDCOMM:while(/\G(.)/gc){
                                if($1 eq '<'){
                                    print OUTF '<'
                                }elsif($1 eq '>'){
                                    print OUTF '>'
                                }elsif($1 eq '"'){
                                    print OUTF '"'
                                }else{print OUTF $1};
                                if (/\G\*\)/gc){
                                   print OUTF '*)';
                                   last OLDCOMM
                                }elsif(/\G\Z/gc){last OLDCOMM
                                                      unless $_=;
                                                      print OUTF "\n"
                                };
                       }
         }elsif(/\G\Z/gc){print OUTF "\n";last A
         }elsif(/\G(.)/gc){
         	                if($1 eq '<'){
                                    print OUTF '<'
                                }elsif($1 eq '>'){
                                    print OUTF '>'
                                }elsif($1 eq '"'){
                                    print OUTF '"'
                                }else{print OUTF $1}
         };redo A
} };

print OUTF '';
close OUTF;