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

"but i want to know if 1 line solution is there"

Really? So whatever solution you have, make it fit on one line. Since you are asking for some code to do this, I'm guessing you currently have nothing working. Will you remember what one line of code will do in a years time?

When people ask for one liners, I often wonder why. Sure you could golf and obfu something which spans multiple lines into one line, but you've just mad it less readable (and arguably less maintainable) for the next person who has to work with your code.

I'm still not exactly sure what your question is, do you have HTML you wish to work with? If so are you using any modules for parsing the HTML source? If so is the module source one line long? :P

Martin

  • Comment on Re: Fast way - get array elements > 4 chars

Replies are listed 'Best First'.
Re^2: Fast way - get array elements > 4 chars
by Zen (Deacon) on Mar 23, 2009 at 15:28 UTC
    One liners are great for command line magic. What sed and awk were used for (and still are, I guess).

      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

Re^2: Fast way - get array elements > 4 chars
by imrags (Monk) on Mar 23, 2009 at 17:06 UTC
    I know marto why i need 1 line...
    Not necessarily to maintain it for sure! :)
    Thx for your replies , everyone! :)
    Raghu

      you know why it is yet if we know what it is we help you help yourself

      Bad attempt at my first kaiku. For some reason your reply looked like a haiku to me. lol


      ___________
      Eric Hodges