in reply to return codes from embedded subroutines
If this is the case, your 'exit' return value isn't going to magically appear in $@. You'll need to examine the value of $? if you want to do it that way (but be warned, the value of this will need to be << 8'd to get at the number you passed to exit).
Obviously, the first method is far more efficient and practical than evaluating code. I hope I'm not misunderstanding what you're doing here. You may be interested in perlsub and documentation for eval and perlvar (for $? and $@).sub some_sub { ... return 5; # not 'exit', as this terminates the script } $returned = &some_sub; # 5 eval "exit(&some_sub)"; # exits block with return value of 5 $returned = $? << 8; # 5
|
|---|