エディタ持ってなかったから、

fp = fopen("a.pl","wt");

fprintf(fp,"#! /usr/local/bin/perl\n");
fprintf(fp,"print 'Hello World';");
・
・
・