in reply to Getting the Behavior of the "file open or die" Pragma but with a Program Pause
This is a global problem -- not just specific to the "open or die" situation you mentioned in your post. If you wish to solve it in a way that makes any calls to die result in a wait period, you may consider overriding CORE::GLOBAL::die. In this case, you would probably want to inject your wait for enter logic into CORE::GLOBAL::die, after dumping $@ to STDERR, and then exit with a non-zero exit status. brian_d_foy has a nice writeup on overriding CORE::GLOBAL::die.
Additionally, if the "print and wait for diamond operator" idiom feels too clunky, you could:
require ExtUtils::MakeMaker; ExtUtils::MakeMaker::prompt('Please hit enter to exit.', '');
...which encapsulates the ugliness in prompt, from the core module ExtUtils::MakeMaker. The advantage to using prompt is that it also quietly accepts the "default" (ie, doesn't block) if the script is run in a non-TTY environment.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting the Behavior of the "file open or die" Pragma but with a Program Pause
by perldigious (Priest) on Oct 10, 2016 at 16:46 UTC |