http://qs1969.pair.com?node_id=60680
Category: Miscellaneous
Author/Contact Info
Description: This program reads all *.pl files in a given directory and then outputs the script followed by the results to an html file. Any suggestions for improvements, or added robustness would be much appreciated.
#!/usr/bin/perl
(@files)=<*.pl>;
foreach my $file(@files){
    my ($filestart)=$file=~/(.*?)\./;
    open INPUT, $file;
    my $source;
    while (<INPUT>){
       $source.=$_;
    }
    close INPUT;
    $program=$source;
    $source=~s/</&lt;/g;
    $source=~s/>/&gt;/g;
    open FILE, ">$filestart.html";
    *STDOUT=*FILE;
    print "<HTML><BODY bgcolor=ffffff>\n";
    print "<PRE><CODE>";
    print $source;
    print "</CODE"."></PRE>";
    print "<B>Program results:</B>";
    print "<PRE>";
    eval $program;
    print "</PRE>";
    print "</BODY></HTML>";
    close FILE;
}