in reply to Re: YAML, $SIG{__DIE__}, Log4perl, $^S, and eval{}
in thread [SOLVED] YAML, $SIG{__DIE__}, Log4perl, $^S, and eval{}

How about adding use MyModuleWhichExports_die; where MyModuleWhichExports_die exports a custom sub die { } which does whatever you need it to do?

Thanks for that. I did not realize you could overwrite Perl's built-in functions that way. This is pretty much what I am looking for.

Quick (possibly dumb)question:
Is it possible to inline MyModuleWhichExports_die in the main program and have it "export" the custom die() function?
e.g.:

package MyModuleWhichExports_die; # Something like Export's "@EXPORT" list here sub die { CORE::die "New and improved!: @_"; } package main; die "I want to be prefixed with 'New and improved'";

I know I can do that by using the fully qualified name of my custom die() (MyModuleWhichExports_die::die), but that defeats the whole purpose of writing a wrapper so I don't have to change my original die() calls in the code

Replies are listed 'Best First'.
Re^3: YAML, $SIG{__DIE__}, Log4perl, $^S, and eval{}
by Anonymous Monk on Mar 21, 2014 at 14:31 UTC