[tpm] Glob problem

Uri Guttman uri at StemSystems.com
Mon Oct 26 20:21:12 PDT 2009


>>>>> "LREQ" == Liam R E Quin <liam at holoweb.net> writes:

  LREQ> On Mon, 2009-10-26 at 20:59 -0400, Uri Guttman wrote:
  >> >>>>> "a" == arocker  <arocker at vex.net> writes:
  LREQ> [...]
  a> (As the application uses only a single-level directory, recursion, &c.
  a> wasn't an issue.)
  >> 
  >> if so, then why the need for file::find?

  LREQ> "There's more than one way to do it" - if it works, it's fine,
  LREQ> and maybe it'll be easier to extend to subdirectories later ;)

but some ways are MORE equal than others! just because you can bubble
sort and it 'works' doesn't make it a good solution for most sorting
problems. the amount of code and relative complexity of file::find vs a
simple readdir/grep is an issue (or at least it is to me). simpler code
is easier to read, understand and debug and it usually runs faster
too. the OP may keep the code as is but should know about alternative
and probably better solutions for the next time or during a
refactoring. i have seen too much overly complicated code because the
existing solution worked and kept 'working' until it became unworkable
code. you get this way from 36 years of coding. :/ 

and if i had known that the dir scan was only one level deep (a critical
fact missing from the 'problem specification') i would have mentioned
readdir/grep earlier vs glob. i thought there was a special reason for
using glob and he was having issues with it and it was not just a
general shallow dir search. i never recommend glob anyhow if i can help
it vs readdir/grep.

uri

-- 
Uri Guttman  ------  uri at stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


More information about the toronto-pm mailing list