From 331094ec8f904b45f610b8cb88e3327d3a78a901 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 16 Oct 2010 10:43:39 -0300 Subject: [PATCH] ds-catq.pl: allow selecting multiple values and added a test mode. - boom/dist/dk/dk-catq.pl: allow multiple values of a parameter to be selected - boom/dist/dk/dk-catq.pl: new option -t to run in test mode, in which the resulting pages are not downloaded but only the URL leading to them is printed --- boom/dist/dk/dk-catq.pl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/boom/dist/dk/dk-catq.pl b/boom/dist/dk/dk-catq.pl index 44823f4..f97bd2c 100755 --- a/boom/dist/dk/dk-catq.pl +++ b/boom/dist/dk/dk-catq.pl @@ -24,6 +24,11 @@ sub query # --- Read query specification ------------------------------------------------ +if ($ARGV[0] eq "-t") { + $test = 1; + shift @ARGV; +} + $spec = $ARGV[0]; while (<>) { @@ -38,7 +43,7 @@ $key = shift @q; $cat = shift @q; for (@q) { die "not a field=value pair: \"$_\"" unless /\s*=\s*/; - $f{$`} = $'; + push(@{ $f{$`} }, $'); } @@ -91,9 +96,20 @@ for (@q) { for (keys %f) { $field = $col_field{$_}; die "no such field: $_" unless defined $field; - $value = $val{$_}{$f{$_}}; - die "no such value: \"$_\"=\"$f{$_}\"" unless defined $value; - $url .= "&$field=$value"; + for $v (@{ $f{$_} }) { + $value = $val{$_}{$v}; + die "no such value: \"$_\"=\"$f{$_}\"" unless defined $value; + $url .= "&$field=$value"; + } +} + + +# --- Stop here if in test mode ----------------------------------------------- + + +if ($test) { + print "$url\n"; + exit(0); }