http://qs321.pair.com?node_id=384973


in reply to A new idiom -or- I Hate Unless

Both your reordering to place the meat of the statement first, and the use of the or operator in error conditions, are covered in perlstyle. You've chosen well, imo.

Perhaps you will get to a stage of maintainance that you can begin refactoring. Pasted blocks are a prime place to look when you do. A stock comment like '# Factor Fodder' or '# Pasted' will help identify them when that time comes.

Don't blame unless. It's a fine operator, just not the best choice for that statement.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: A new idiom -or- I Hate Unless
by erikharrison (Deacon) on Aug 22, 2004 at 21:32 UTC

    My problem is not so much unless as the problem it tries to fix - namely making doing something when a condition is false readable and clear. It does that, to an extent. But in 90% of the cases the code is for handling an error.

    Marking cut and paste code as such is a great idea. The code needs some documentation anyway. It's all uncommented.

    update: fixed typo
    Cheers,
    Erik

    Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet