tsort-check revision 1.1
1#!/usr/bin/perl 2 3# Written by Marc Espie, 2001. 4# Public domain 5 6%order=(); 7 8open(SORTED, shift) or die "No sorted output\n"; 9while(<SORTED>) { 10 chomp; 11 $order{$_} = $i++; 12} 13close(SORTED); 14 15open(PAIRS, shift) or die "No pairs\n"; 16undef $/; 17$_ = <PAIRS>; 18close(PAIRS); 19@pairs = split(/\s+/, $_); 20while (@pairs > 0) { 21 ($a, $b) = (pop @pairs, pop @pairs); 22 next unless $order{$a} < $order{$b}; 23 die "Bad pair $a $b\n"; 24} 25