Zurück - Hauptseite

Perl Syntax Checker for CGI development

The path name to the perl interpreter must be changed according to the real web server installation. /usr/bin/perl is quite common. - To use this program, it must be uploaded to the CGI directory on your web server. Exec-permissions must be set. The program is driven by a HTTP request, i.e. by entering an URL into your browser.

Life Demo

#!/usr/bin/perl -w
# Syntax check for PERL programs in current directory
# Prints diagnostic output formatted as CGI Response
use strict;
use CGI;
sub perlmain($)
my $q;
my $linebuf="";
my $thisprog="";
my $errlist="";
$q = new CGI;
print $q->header ("text/html");
print $q->start_html( -title => "Check CGI program syntax" );
### Invoke LINUX "ls" for all perl files in this directory
### Redirect its output to PERL filehandle
open MAP1,("/bin/ls *.pl |");
while (<MAP1>)
$linebuf = $_;
chomp $linebuf;
$thisprog = $linebuf;
print "<b>checking $thisprog:</b>\n";
$errlist = `/usr/bin/perl -cw $thisprog 2>&1`;
print "$errlist\n";
print "<br>\n";
close MAP1;
print $q->end_html;
my $globex = perlmain(1);
exit 0;