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"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.