Date:2010-10-17 05:13:21 (8 years 1 month ago)
Author:Werner Almesberger
Commit:046ae8584ee1ccab214624518accf046304c8970
Message:dk-catq.pl: allow selection of top category as well

- boom/dist/dk/dk-catq.pl: category can now include the top-level category
(syntax: top/sub)
- boom/dist/dk/dk-catq.pl: corrected value printed in "no such value" error
message
Files: boom/dist/dk/dk-catq.pl (3 diffs)

Change Details

boom/dist/dk/dk-catq.pl
4141$id = shift @q;
4242$key = shift @q;
4343$cat = shift @q;
44($topcat, $cat) = ($`, $') if $cat =~ m|/|;
45
4446for (@q) {
4547    die "not a field=value pair: \"$_\"" unless /\s*=\s*/;
4648    push(@{ $f{$`} }, $');
...... 
5759if ($q[1] =~ /<title>Digi-Key</) {
5860    undef $found;
5961    for (@q) {
62        $on = $1 eq $topcat if
63            defined $topcat && /catfiltertopitem>\s*(.*?)\s*</;
64        next if defined $topcat && !$on;
6065        next unless /Cat=(\d+)[&"].*?>\s*(.*?)\s*[(<]/;
6166        next if $2 ne $cat;
6267        $found = $1;
...... 
98103    die "no such field: $_" unless defined $field;
99104    for $v (@{ $f{$_} }) {
100105        $value = $val{$_}{$v};
101        die "no such value: \"$_\"=\"$f{$_}\"" unless defined $value;
106        die "no such value: \"$_\"=\"$v\"" unless defined $value;
102107        $url .= "&$field=$value";
103108    }
104109}

Archive Download the corresponding diff file

Branches:
master



interactive