Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Getting the Behavior of the "file open or die" Pragma but with a Program Pauseby davido (Cardinal) |
on Oct 10, 2016 at 16:17 UTC ( [id://1173666]=note: print w/replies, xml ) | Need Help?? |
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:
...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
In Section
Seekers of Perl Wisdom
|
|