richmusk has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to execute a perl program from within a perl program ??? also ... how can I launch a text editor ... the command
system "xemacs results.txt"
doesn't work ... nor does the exec command ... is there another ???

Replies are listed 'Best First'.
Re: Executing Perl Programs
by suaveant (Parson) on Jul 12, 2001 at 17:42 UTC
    you can execute a perl program from a perl program using backticks or system, or you can use the eval command to interpolate perl code at runtime, though this is somewhat different than executing a perl program in general, because whatever you eval really becomes part of your program, not an entity unto itself... you could also use exec if you want to leave your current script and just start running the new one. There is always more than one way to do it.

    As for the xemacs call... maybe your DISPLAY or PATH environment variables are not set right? It should work alright. Look at the exit value, the way to do that is described in system

                    - Ant

Re: Executing Perl Programs
by OzzyOsbourne (Chaplain) on Jul 12, 2001 at 19:23 UTC

    You seem to be working in *nix, but I proffer the windows solution for completeness.

    Win32::Process::Create($ProcessObj, "c:\\location of perl\\perl\\bin\\perl.exe", "perl.exe script.pl, 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport();

    -OzzyOsbourne

Re: Executing Perl Programs
by TrinityInfinity (Scribe) on Jul 12, 2001 at 18:27 UTC
    I have a program to generate a date string for me that I use in several programs. When it runs, its only output is the one line with the date I want on it, so I use it in other programs as:
    $date = `textclock.cgi`;
    ..and it works great! I hope this helps for your purpsoses.