in reply to Idioms considered harmful

While I can see your point, it does raise the question of where you want to draw the line; I've been questioned over the last week on the use of:

Some of these I could replace with longer code with the same effect (the qw) or remove completely with no ill effects (the non-capturing parentheses were just being a habit). But I was somewhat horrified at being instructed to put in a comment explaining that perl uses eval for exception handling.

So, we really need to distinguish between expected and unexpected idioms. And that's going to be a hard line to draw...

--
Tommy
Too stupid to live.
Too stubborn to die.

Replies are listed 'Best First'.
Re2: Idioms considered harmful
by blakem (Monsignor) on Oct 15, 2002 at 19:00 UTC
    map { MAPCLAUSE } grep { GREPLCAUSE }
    Can be rewritten as:
    map { GREPCLAUSE ? MAPCLAUSE : () }
    For instance, if you want a list of the squares of the first five odd numbers, either of these will work.
    @odds_squared = map { $_**2 } grep { $_%2 } 1..10; @odds_squared = map { $_%2 ? $_**2 : () } 1..10; Result: 1 9 25 49 81

    -Blake

Re: Re: Idioms considered harmful
by John M. Dlugosz (Monsignor) on Oct 15, 2002 at 19:21 UTC
    Well, language features that involve a keyword are easy to look up in the reference manual.

    A combination of features used a certain way is harder to "look up" anywhere, and requires a human mentor.