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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.