|Do you know where your variables are?|
Getting the Behavior of the "file open or die" Pragma but with a Program Pauseby perldigious (Priest)
|on Oct 10, 2016 at 15:31 UTC||Need Help??|
perldigious has asked for the wisdom of the Perl Monks concerning the following question:
Hello fellow Monasterians,
I'm asking for opinions on possibly better ways to do the following.
I'm really just forcing the script to pause so that the user can see the error message. When I just used the standard file open() or die pragma I would get frequent calls from people attempting to manually run scripts I'd written saying they weren't working (because the window would just close immediately), and the vast majority of the time it would simply be because they had an output file open in another program therefore denying permission for the script to write to it. The my $pause = <STDIN>; pause so they can read the message largely fixed this annoyance for me, but every time I use it I cringe a little and wonder if there isn't a better, perhaps more perlish way of doing this.
This code doesn't give me the same cringe as my kludge function did. I tested it with an .exe generated via PAR::PACKER and it works as expected for the two cases above (on my machine anyway) and doesn't cause any pause if there are no file open dies.
Much appreciated, as always.
I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious