if($^O =~ /mswin32/i) {exit} open(FOO,">pdl.c"); print FOO <<'nosubs'; /****************************** * pdl.c - perldl spawner * Works around a problem with many unices that you can't use an interpreter * to run an interpreter -- so "#!/usr/bin/perldl" won't work. * This is a compiled piece of code that launches perldl "directly", * so that the poor kernel's mind isn't blown. * * If you feed in a single non-switch argument it gets prepended with a * "-" to let perldl know that it's an input file. That way you can be lazy * and say "#!/usr/bin/pdl" at the top of your script. * * Don't modify this .c code -- modify the generator, pdl.PL, instead. * * CED 21-Jul-2004 */ #include #include #include #include #include main(int argc, char **argv) { char perldl[BUFSIZ]; int pipes[2]; int pid,i; int status; if(pipe(pipes)) {perror; exit(1);} pid = fork(); if(pid==0) { dup2(pipes[1],1); dup2(pipes[2],2); system("which perldl"); exit(0); } read(pipes[0],perldl,BUFSIZ); pid = wait(&status); if(! WIFEXITED(status) ) { fprintf(stderr,"Hmmm... couldn't seem to find perldl anywhere. Quitting.\n"); goto exit; } /* Remove trailing newline */ for(i=0;i