I think eval might not be the right tool to use here. In Perl, eval takes a string (or block) of Perl code and executes it. If you put a backtick expression where it's looking for a string, it's going to take the output of the shell command in the backticks and then try to execute it as Perl. Here's a demonstration:
sub whoops {
print "whoops() called\n";
}
eval `echo whoops`;
print $@ ? "EVAL ERROR: $@\n" : "no error!\n";
eval `echo no_such_sub`;
print $@ ? "EVAL ERROR: $@\n" : "no error!\n";
__END__
whoops() called
no error!
EVAL ERROR: Bareword "no_such_sub" not allowed while "strict subs" in
+use at (eval 2) line 1.
I'm guessing that what you want to do is:
- Run an external command.
- Get its output.
- Find out if it died (gave an abnormal exit status).
- Find out also if it spit out a warning (output anything on STDERR).
I think the responses in Parsing STDERR and STDOUT at the same time might help here. I think that IPC::Run can do all of this, but I haven't used it myself.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.