Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Printing POD info to terminal window without exiting

by davido (Cardinal)
on Aug 05, 2021 at 15:04 UTC ( [id://11135619]=note: print w/replies, xml ) Need Help??


in reply to Printing POD info to terminal window without exiting

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135619]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found