in reply to Is too little too much? Coding under the microscope...

Can you understand it when it's shortened? If you add a comment, can the other people who'll work on the program understand it?

In theory, the fewer lines of code you have, the less bugs. You might want to move sort to the right side of the assignment in the short version, though. :)

opendir(LOGS, '.') or die "Can't open directory: $!"; print join("\n", sort map { -M $_ } grep { /\.log/ } readdir(DIR)); closedir(LOGS);
I'd probably throw a \z anchor at the end of the grep regex, too.

Replies are listed 'Best First'.
Re: Re: Is too little too much? Coding under the microscope...
by snafu (Chaplain) on Jun 28, 2001 at 09:52 UTC
    Yeah, I have much more to learn about map{} and sort{}. I tried the sort on the right side of the assignment but I was trying a more complicated version of sort because of what I was/am trying to achieve with it but nothing seemed to work. I am still working on this part as well. This script should be pretty nifty when I am done with it though.

    ----------
    - Jim