dgaramond2 has asked for the wisdom of the Perl Monks concerning the following question:
I want to provide the users of my command-line script a way to select some objects based on one or more criteria. I figure that the syntax for Unix's find is ideal as most of them are already familiar with it. Examples:
# select all stones % stone.pl % stone.pl '*' # select only stones whose names match a wildcard % stone.pl 'p*' # blue stones starting with p % stone.pl 'p*' -color blue # blue or green stones % stone.pl 'p*' -color blue -o -color green # discard stones tagged as expensive and not tagged as valuable % stone.pl -tag +expensive -and -tag -valuable -discard
For converting wildcard to Perl's regex, there's File::KGlob2RE. The hard part for me is implementing the multiple criteria syntax: 'expr -and -expr', 'expr -or expr', '( expr )' and '-not expr'.
Pointers would be appreciated. Hopefully there's something on CPAN I can use as a base.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to implement something similar to Unix's find syntax?
by leocharre (Priest) on May 25, 2007 at 10:00 UTC | |
by bart (Canon) on May 26, 2007 at 10:09 UTC | |
by dgaramond2 (Monk) on May 26, 2007 at 00:14 UTC | |
|
Re: How to implement something similar to Unix's find syntax?
by jettero (Monsignor) on May 25, 2007 at 11:01 UTC | |
|
Re: How to implement something similar to Unix's find syntax?
by merlyn (Sage) on May 25, 2007 at 18:07 UTC | |
|
Re: How to implement something similar to Unix's find syntax?
by moritz (Cardinal) on May 25, 2007 at 10:06 UTC | |
|
Re: How to implement something similar to Unix's find syntax?
by sanPerl (Friar) on May 25, 2007 at 12:29 UTC | |
by moritz (Cardinal) on May 25, 2007 at 12:59 UTC |