in reply to Regex Basics
- as a good habit, follow glob with an expression that includes the '*' in single quotes -- "*" is prone to be dereferenced by Perl before the glob() gets called.
- grep and glob could be combined more succinctly and therefore readably - sometimes opendir etc fits better than glob in the code - in this case both seem to have their place.
- where a path is used more than once in the code, put it in a variable early on to avoid data duplication (maintainability). Consider also putting paths, regexps and filenames in configuration files to avoid hardcoding completely.
For example ...
my $tree = "/appl/perform/workspace/htdocs/node_reports"; opendir my $dh, $tree or die $!; for my $node ( grep !( /^\./ || /^lost\+found$/), readdir $dh ) { print "$_\n" for grep !/^business_use\.$node$/, glob join( '/', $t +ree, $node, '*' ); } closedir $dh;
-M
Free your mind
|
|---|