Hello
grinder,
your way is much shorter and perhaps easier to read.
The reasons why I wrapped it into an unless-else-block are the following:
- If I post code for beginners or slightly enhanced perl-programmers, I try to post code that is as easy and flexible as possible; if they want to do something before die, the unless-construct is much easier to enhance (well, you could do e.g. open (CMDREAD, ...) or &DoSomething and die(...); or the like, but there you have to care about the returnvalue of &DoSomething and it becomes more complicated than necessary (seen so on www.perl.de) ).
- The else-Block is not neccessary with die or return or the like. But if you replace the die with warn, all of a sudden "else" becomes very important. And some scripts are changed very often over the years (because requirements change or whatever), so I try to build full logical blocks whenever possible.
- I hardly use die in my programs, because with the stuff I usually write it is often not ok to just die with a message; the script should try to solve the error by itself if possible or at least find some additional information about it or do some cleaning up, and so the "open or die" is idiomatic perl, but very often not usable to me. And so, in most of my posted code, die is just a placeholder for doing some better errorhandling.
I'm very interested what other people think about this issue, so I'd be glad about lots of comments.
Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"