Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Is too little too much? Coding under the microscope...

by chromatic (Archbishop)
on Jun 28, 2001 at 09:35 UTC ( [id://92187]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://92187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found