Were I to guess you're running W32:
#!/usr/bin/perl print "Success Ran Here"; =head path\to\success>perl -e "@var=`success.pl`;print @var;\n" Success Ran Here path\to\success> path\to\success>perl -e "@var=system(\"success.pl\") or die \"can\'t r +un\";print \"@var \n\";" Success Ran Here0 path\to\success> # the "0" is errno from system ie, no error; # were you executing this from the same dir as holds "success.pl"? path\to\success>perl -e "@var=exec(\"success.pl\") or die \"can\'t run +\";print \"@var \n\";" and... path\to\success>perl -e "@var=exec (\"perl success.pl\") or die \"can\ +'t run\n\";print \"@var \n\";" path\to\success>Success # note the blank line before the last prompt, and the location of t +he word "success" # perldoc -f exec: The "exec" function executes a system command a +nd never returns* # If your OS (windoze?) does not have perl associated with .pl, thi +s won't work, and even if it does, IIRC, using "exec" won't assign an +ything to $var usefully, as "never returns" means everything after th +e "exec(..." won't be executed. In effect, the "exec(..." is like "ex +it;" path\to\success>perl success.pl # ie, this file Success Ran Here path\to\success> =cut open(FH, "success.pl"); @var=<FH>; close(FH); print $var;
and if I guess *nix (as I do from the "-1" in OP's example 2):
ww@GIG:~/pl_test$ perl -e '@var=`success.pl`;print @var;\n;' wheelerw@GIG:~/pl_test$ # nada (addressed in a prior reply) ww@GIG:~/pl_test$ perl -e '@var=system("success.pl") or die "cant run" +; print "@var \n";' -1 ww@GIG:~/pl_test$ # system error; see reply above ww@GIG:~/pl_test$ perl -e '@var=`success.pl`;print "@var\n";' ww@GIG:~/pl_test$ # note blank line between prompts ww@GIG:~/pl_test$ perl success.pl Success Ran Here ww@GIG:~/pl_test$ # newline added in 'print $var . "\n";' in *nix script =cut
Oh yes, this summary is quite late. Thank the alarm that sent us running to a "odor of gas in a structure" call... :-)
In reply to Re: Running perl scrit from a perl script
by ww
in thread Running perl script from a perl script
by ikuzmanovs
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |