#!/usr/bin/perl -w # $Id: kico,v 1.3 2008/02/14 01:43:54 gilles Exp gilles $ use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $debug = 0; my $catalog_separator = ";"; print header(), start_html("Recherche de composants"), h1("Recherche de composants"),"\n", start_form(), "Valeur : ", textfield("SEARCHED_TEXT"),"\n", submit(-value=>'Cherche Médor'),"\n", end_form(),"\n", ; my $searched_text = param("SEARCHED_TEXT"); my @all_composants = read_catalog("kicad_composants.txt"); if ( defined($searched_text) ) { print h2("Résultats"),"\n"; my @matched_composants = grep { m/$searched_text/i } @all_composants; print "
\n";
	
	foreach my $composant (sort @matched_composants) {
		chomp($composant);
		
		my ($reference, $family, $url) 
			= split($catalog_separator, $composant);
		
		$debug and print "($reference, $family, $url)\n";
		
		next unless ($reference);
		print a({href=>"$url"}, $reference), " $family $url \n";
	}
	print "
"; } print end_html(); exit; sub read_catalog { my ($file) = @_; open(FILE, "< $file") or die "$file $!"; my @file = ; close FILE; return @file; }