From e985130b55aa0b39abc83a1ebc77166a60840b74 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 14 Apr 2004 16:19:38 +0000 Subject: [PATCH] resistor converter mk 1 --- farnell/farnell-resistor-convert.pl | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 farnell/farnell-resistor-convert.pl diff --git a/farnell/farnell-resistor-convert.pl b/farnell/farnell-resistor-convert.pl new file mode 100755 index 0000000..d8ed939 --- /dev/null +++ b/farnell/farnell-resistor-convert.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl +# ways to invoke: +# 1. Get a search list from farnell and feed HTML source to +# this script with no args. Will produce part number list. +# 2. Feed one or more outputs from farnell-find to +# this script with args ... +# where is the re for the first part of the mfr +# code and is the words of the part name prefix. +if (@ARGV>=2) { + ($kind,@prefix)= @ARGV; + while () { + if (m/^Avail\s/) { + undef $value; + } elsif (m/^Description\s+\[$kind (\d[0-9MKR]+)\]\s+RESISTOR/) { + $value= lc $1; + } elsif (m/^Description\s+(\S.*)/) { + print "# $1\n"; + $value= ''; + } elsif (m/^Item\s+([-0-9]+)$/) { + die unless defined $value; + next unless length $value; + printf "%s\t%s\n", join(' ',@prefix,$value), $1; + undef $value; + } + } +} elsif (!@ARGV) { + while () { + if (m/viewproductdetails.*\?prodId\=(\d{3})(\d{3,7})\"/) { + print "$1-$2\n" or die $!; + } + } +} else { + die; +} -- 2.30.2