#!/usr/bin/perl use strict; use CGI; print "Content-type: text/plain\n\n"; my $q=new CGI; my $codes=$q->param('c_code'); my $file = "code.cpp"; open(FH, ">$file"); ### Must chmod Before writing, system("chmod 0777 code.cpp"); ### Can't create and change mode???? print FH "$codes"; close(FH); &run; exit(0); sub run { system("gcc code.cpp"); system("a.out/>result.txt"); open(F,"result.txt"); while() { print $_,"\n"; } close(F); }