http://www.perlmonks.org?node_id=661927


in reply to Re: Anyone want to compress this a little more?
in thread Anyone want to compress this a little more?

While I thought the original question was lacking something, I also think your response is not particularly useful either.

The original poster should use the <code> tags to show the program in the correctly formatted way. If they had done that, the two lines which you chose to discuss would have kept their square-brackets, and thus worked much better than you indicate. If you look closely, the $i is underlined, as $i, because perlmonks writeup ate the brackets, not because the poster's program itself was broken (in that way).

To the original poster: an impersonal general request like "here's some code to improve if you like" won't gather as much useful response as a direct or specific question. Even "I'm not happy with the way this code looks, how would you make it better?" would probably be enough to get more folks interested in collaborating. In brief, if it doesn't sound like you care about it yourself, why should we?

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^3: Anyone want to compress this a little more?
by olus (Curate) on Jan 11, 2008 at 18:32 UTC
    I think the original post lacks a lot of things, and <code> is the least of them.
    Had he used the <code> tags, compile errors would still appear.

    The <code> tag would not make the comma show up on opendir lines neither help in resolving $workingDir to be $workDir or even $fileToLoad[$i] as an item of @filesToLoad

    Since the question is not asking what on earth is the code doing or why it was not working, he challenged everyone tho write something that does the same, but smaller.

    Add the square brackets to both scripts and the output will still be the same for both.
Re^3: Anyone want to compress this a little more?
by naveed010 (Acolyte) on Jan 11, 2008 at 18:00 UTC
    Sincerest apologies to all, and thank you ed for the constructive response. I'm new to the monks site. I do care about it. I'm in the process of writing it, haven't compiled it yet and the thought came to me, there must be a way to compress this down such that I don't need to cut/paste/tweak the same 6 lines. I just tossed it out there as an afterthought as I continute to grind this out. I had hoped my breif explanation at the top of the message was sufficient to explain what I was trying to do. Again, sorry.
      I'm in the process of writing it, haven't compiled it yet and the thought came to me, there must be a way to compress this down such that I don't need to cut/paste/tweak the same 6 lines.

      I personally believe that you should take those six lines and put them into a sub. Possibly put the sub into a module. I must admit that didn't follow the whole discussion because it looked like a mess, but this is a general purpose piece of advice that should apply to any situation in which you have the feeling you're copying and pasting too much.

      --
      If you can't understand the incipit, then please check the IPB Campaign.
      naveed010,

      Welcome to the Monastery and take some time to browse its sections. Particularly Tutorials.
      Read How (Not) To Ask A Question. That will help you getting help from others.

      As for the question itself, in my first reply I'm being honest (although it may not seem so) when I tell you to worry about making the code readable.
      In that same response I showed a revised version of the code, it happens to have more lines but still I think it is more readable. Take a look at it.
      And, surprise, it also answers the question you are now asking. The repeating parts are in a separate sub.

      The second reply is, of course, a joke.