in reply to Eval and system()

You get an error on the second example, because the syntax is wrong (missing ") and this is checked in the compile phase.
So your example doesn't run and thus no $@.

The next example dies because system() returns the exit-code of the command it runs.
Unix commands return 0 on success, which is false for Perl, hence it dies.

Update: fixed typos

Replies are listed 'Best First'.
Re: Re: Eval and system()
by camelman (Sexton) on Sep 05, 2001 at 17:13 UTC
    Sorry about that! I meant:
    eval { system("fake_command") }; print $@;
    which still doesn't print $@, I guess because of it being caught in the compile phase. Thanks . . . Kevin
      It doesn't mean an error in eval when the command in system() fails.

      To check for that you can probably use:

      eval { system("false") and die "command 'false' went wrong!"}; print $@, "\n"