Suresh Govindachar wrote:
 I have been trying to not die when calling perldoc,
 but the code below keeps dying inside perldoc.

 The code below does show that eval is happening
 at runtime, and that the syntax used for shutting
 off __DIE__ does work when perldoc is not involved.

Hi,
First off, I must confess I haven't been following this thread too closely. As far as I've understood your code, this might be about dying inside eval blocks. If you have a die-handler installed, it does get called inside evil which has bitten me a number of times.

Perldoc warns about this in several places. I did a bit of research and these snippets might help in devicing a temporary fix at least.

perldoc -f eval:
Quote:
Due to the current arguably broken state of "__DIE__" hooks, when using the "eval{}" form as an exception trap in libraries, you may wish not to trigger any "__DIE__" hooks that user code may have installed. You can use the "local $SIG{__DIE__}" construct for this purpose, as shown in this example:

# a very private exception trap for divide-by-zero
eval { local $SIG{'__DIE__'}; $answer = $a / $b; };
warn $@ if $@;
End quote.

I believe this is the mechanism you've used, that is, setting a local die-handler in order not to die.

However, even if this doesn't fix the problem for some reason, the die documentation offers another fix.
perldoc -f die
Quote:
the $SIG{__DIE__} hook is currently called even inside eval()ed blocks/strings! If one wants the hook to do nothing in such situations, put

die @_ if $^S;

as the first line of the handler (see "$^S" in perlvar). Because this promotes strange action at a distance, this counterintuitive behavior may be fixed in a future release.
End quote.

Oddly enough, the die and eval docs give different fixes for the same problem and it is easier to see when quoting verbatim.

Lastly, here's the bit about the ^S scalar referenced above.
perldoc -f perlvar
Quote:
$^S Current state of the interpreter.

$^S State
undef Parsing module/eval
true  (1)Executing an eval
false (0) Otherwise

The first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers.
End quote.

Hope this helps.

--
With kind regards Veli-Pekka Tätilä ([EMAIL PROTECTED])
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to