[tpm] Glob problem

Uri Guttman uri at StemSystems.com
Tue Oct 27 10:48:44 PDT 2009


>>>>> "a" == arocker  <arocker at vex.net> writes:

  >> use File::Slurp ;
  >> 
  a> A constraint I didn't specify was "use only stuff in the standard
  a> distribution, where possible". My powers don't extend to installing from
  a> CPAN, and the person who can is busy doing other things I need done.

that is always a lousy constraint. seen it too often in some places.

  >> my ($file_name) = map "$from_dir\\$_", grep /${job_no}XX-.*\.txt/,
  >> read_dir $from_dir ;
  >> 

  a> Frankly, I don't see that as any great improvement. (I put the regex value
  a> in a variable so I could make changes for testing purposes, without
  a> disturbing the selection code.)

using a var is fine. the main win is perl regexes vs globbing which is
very limited in matching power. globs can keep the prefix dir for you
which is nice. if i ever get the prefix option to read_dir i could even
make it a new function like read_dir_prefix and then the code would be
like:

	my ($file_name) = read_dir_prefix qr/${job_no}XX-.*\.txt/, $from_dir ;

and that reads pretty well and is about as short as you can get. still
cpan but lobby and it could be in core one day! :)

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