You already answered your own question by following up to state that -exitval => 'NOEXIT' works. I had found this to work just fine, as well. But it wouldn't be Perl if it didn't arouse curiosity. I was curious if I could override CORE::GLOBAL::exit effectively. Turns out I can (though this isn't to say I should):
#!/usr/bin/env perl use strict; use warnings; our $override_exit = 0; BEGIN { no warnings 'redefine'; *CORE::GLOBAL::exit = sub :prototype(;$) { if ($override_exit) { warn "EXIT_OVERRIDE\n"; } else { CORE::exit($_[0] // 0); } }; } use Pod::Usage; { local $override_exit = 1; print "Calling pod2usage(1)\n"; pod2usage(1); print "We are still here after overriding exit.\n"; } print "calling pod2usage with -exitval => 'NOEXIT'\n"; pod2usage(-exitval => 'NOEXIT'); print "We are still here after using -exitval => 'NOEXIT'.\n";
This produces the following output:
Calling pod2usage(1) EXIT_OVERRIDE We are still here after overriding exit. calling pod2usage with -exitval => 'NOEXIT' We are still here after using -exitval => 'NOEXIT'.
So this demonstrates that NOEXIT works, and that overriding CORE::GLOBAL::exit can work.
Dave
In reply to Re: Printing POD info to terminal window without exiting
by davido
in thread Printing POD info to terminal window without exiting
by cr8josh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |