in reply to Doing stuff in specific directories on Unix

Any advise on improving this because it does work but want to make sure I am doing it the most efficient way.

Worry less about efficiency and more about maintainability. There's no reason to put all of that right in the call to find(), is there? Why not make it more readable and easier to extend later by separating the part where you construct the directory names like this

use strict; use File::Find; my $base = '/perl/bin'; my @dirs = map "$base/$_", qw( FirstOne SecondTwo ThirdThree); find( \&Searcher, @dirs ); # ...

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Doing stuff in specific directories on Unix
by chromatic (Archbishop) on Jul 28, 2003 at 20:22 UTC
    There's no reason to put all of that right in the call to find(), is there?

    Sure there is. If he's just trying to get it done, right now, and he's not likely to use this program ever again, why bother? If he does use it again and needs to make it more flexible, it's just code. He can generalize then.

    While half of the sins in the programming world come from premature optimization, easily another half come from premature generalization. (Yes, there are more sins in programming than you'd believe.) Back in 1999, I just wanted a working web browser, not a cross-platform framework for writing applications in XML and JavaScript.

      If he's just trying to get it done, right now, and he's not likely to use this program ever again, why bother?

      Well, he already said it worked and that he was trying to improve it.

      Back in 1999, I just wanted a working web browser, not a cross-platform framework for writing applications in XML and JavaScript.

      Back in 1999? Heh. That's all I want today.

      -sauoq
      "My two cents aren't worth a dime.";
      
        Thanks to both of you and I appreciate the opinions and your advise. Thanks again!