--- a/exigrey.pl Wed Jan 03 09:36:10 2007 +0000
+++ b/exigrey.pl Wed Jan 03 10:17:54 2007 +0000
@@ -10,7 +10,7 @@
!ME! --list [db] # list all items
!ME! --stat [db ...] # print short statistic
!ME! --clean [days [db ...]] # remove items not used since <days> days
- !ME! --dbs # list dbm files in default directory
+ !ME! --dbs [glob] # list dbm files in default directory
Defaults: delay: !$DEFAULT{delay}!
db: !$DEFAULT{db}!
@@ -39,6 +39,7 @@
my $opt_clean;
my $opt_dbs;
+sub getDBs($);
sub iterate(\%$);
MAIN: {
@@ -72,7 +73,9 @@
}
if ($opt_stats) {
- foreach ((@ARGV ? @ARGV : $DEFAULT{db})) {
+ @ARGV = ($DEFAULT{db}) unless @ARGV;
+ @ARGV = getDBs($ARGV[0]) if $ARGV[0] =~ /[\*\?]/;
+ foreach (@ARGV) {
my %h;
my $db = connectDB(\%h, $_);
@@ -107,6 +110,8 @@
if ($opt_clean) {
my $cut = time() - (86400 * (@ARGV ? shift : 7));
+ @ARGV = ($DEFAULT{db}) unless @ARGV;
+ @ARGV = getDBs($ARGV[0]) if $ARGV[0] =~ /[\*\?]/;
foreach (@ARGV ? @ARGV : $DEFAULT{db}) {
my %h;
my $tmp = tmpfile();
@@ -126,7 +131,7 @@
}
if ($opt_dbs) {
- print join("\n", glob(getDBDir() . "/*")), "\n";
+ print join("\n", getDBs(shift || "*")), "\n";
exit 0;
}
@@ -136,6 +141,10 @@
}
}
+sub getDBs($) {
+ glob(getDBDir() . "/$_[0]");
+}
+
# Helper to iterate over our hash and call the passed
# "callback" function (item, v0, v1, delta)
sub iterate(\%$) {