File: chemtest.pl

package info (click to toggle)
chemeq 2.9-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,524 kB
  • ctags: 534
  • sloc: cpp: 1,107; yacc: 302; ansic: 123; perl: 118; makefile: 95; sh: 11
file content (41 lines) | stat: -rw-r--r-- 964 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/local/bin/perl
# -*- coding: utf-8 -*-

$lignes_de_reponse = 6;

while(chomp($essai = <STDIN>)){
    if(length($essai) != 0 && substr($essai,0,1) ne "#"){
	for ($i=0; $i < $lignes_de_reponse; $i++){
	    chomp($tmp=<STDIN>); @reponse[$i]=$tmp;
	}
	$essai_ = $essai;
	$essai_ =~ s/\'/\\\'/g;
	@args = ("echo \"$essai_\" | chemeq > /tmp/tmp.1");
	system @args;
	open (TMP,'/tmp/tmp.1');
	$ok=1;
	for ($i=0; $i < $lignes_de_reponse; $i++){
	    chomp($tmp=<TMP>); @result[$i]=$tmp;
	    if (@result[$i] ne @reponse[$i]){$ok=0;}
	}
	if ($ok){print "OK\t\t$essai\n";}
	else{
	    print "***ERREUR***\t$essai\n";
	    for ($i=0; $i < $lignes_de_reponse; $i++){
		if(@result[$i] ne @reponse[$i]){
		    print "ligne $i : on attendait\n";
		    print "\t\"@reponse[$i]\"\n";
		    print "on a trouvé\n";
		    print "\t\"@result[$i]\"\n";
		}
	    }
	}
    } else {
	if ($essai =~ /[a-zA-Z]/) {print "$essai\n";}
    }
    
}

system ("(cd /tmp; rm -f tmp.1)");