http://qs321.pair.com?node_id=767534


in reply to eval-ling code in another process

Then how do I know if $? is the custom exception I have been looking for? All I get is WEXITSTATUS($?)=255 for any 'die' signal.

Replies are listed 'Best First'.
Re^2: eval-ling code in another process
by wol (Hermit) on Jun 02, 2009 at 15:48 UTC
    Consider replacing
    die "Something informative";
    with
    warn "Something informative"; exit $customCodeToDetectInParent;

    --
    use JAPH;
    print JAPH::asString();

Re^2: eval-ling code in another process
by Errto (Vicar) on Jun 02, 2009 at 15:29 UTC
    die only writes its "exception" to the standard error stream, so you'll need to capture that output. In Unix you can do this using a piped open like open my $fh, 'othercommand 2>&1 |'; and then reading $fh. Or you could even do my $response = `othercommand 2>&1`; and parse out the result. Not sure if that works in Windows. You could also try IPC::Open3. I don't think Win32::Process will let you capture that.