in reply to Problems with eval
It's also worth pointing out that
When perl encounters a back-ticked string, it passes the contents of the string (after interpolating any embedded vars) to a system shell for processing, captures any output from the command, and returns that to the calling program once the command completes. eg.
print "`set tmp` returned:", `set tmp`, $/;
results in
`set tmp` returned:TMP=D:\TEMP
on my system.
If you need to know the exit status of the command being issued, then you need to look at $? see perlman:perlvar. eg.
print "`set tmp` returned:", `set tmp`, " and had an exit code of:$?", +$/; print "`set non-existant-env` returned:", `set non-existant-env`, " an +d had an exit code of:$?",$/;
gives
`set tmp` returned:TMP=D:\TEMP and had an exit code of:0 Environment variable non-existant-env not defined `set non-existant-env` returned: and had an exit code of:256
Finally, you're almost certainly better of using the system function (see perlamn:perlfunc), as Aristotle suggest's, but don't be confused by the => ! This is colloqually known as 'the fat comma', and when used as Aristotle has, it is simply equivalent to a comma, and is used here rather than a comma simply for emphasis. I point this out as I spent several hours searching the docs trying to find out what it meant when I first encountered it in a reply to one of my questions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problems with eval
by Aristotle (Chancellor) on Sep 07, 2002 at 00:06 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2002 at 00:20 UTC |