in reply to Re: Fast way - get array elements > 4 chars
in thread Fast way - get array elements > 4 chars

One liners are great for command line magic. What sed and awk were used for (and still are, I guess).
  • Comment on Re^2: Fast way - get array elements > 4 chars

Replies are listed 'Best First'.
Re^3: Fast way - get array elements > 4 chars
by marto (Cardinal) on Mar 23, 2009 at 15:47 UTC

    Oh I agree, however often when I see someone ask for a one liner in context of a script it sets of an alarm bell. For example, here the OP has not posted any code they've attempted to use to solve the problem, and to be honest, I'm not 100% sure what the actual question being asked is.

    My point being that in circumstances such as this giving someone the answer may be counter productive, since they've been given the solution they asked for, and the script 'works' they may not learn what the code they've been given does, so there is a good chance it will remain undocumented, and perhaps forgotten in the mists of time.

    My issue is not with one liners per se, but consider the following old adage:

    Give someone a fish and they can eat for a day. Teach someone to fish and they can provide their own meals, and in time, teach others :)

    Thanks

    Martin

      Give someone a fish and they can eat for a day. Teach someone to fish and they can provide their own meals, and in time, teach others
      I thought the saying was:
      Give someone a fish and they can eat for a day. Teach someone to fish and they will sit in a boat the whole day and drink beer.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        At the moment your saying is much more appealing to me :)

        Martin