From: Ian Jackson Date: Sun, 2 Feb 2014 20:18:49 +0000 (+0000) Subject: autodie X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=appendix-a6.git;a=commitdiff_plain;h=6c044868abff470bc659ffd315bcf5a1cea20ded autodie --- diff --git a/parse b/parse index e176ecc..16f0926 100755 --- a/parse +++ b/parse @@ -1,13 +1,14 @@ #!/usr/bin/perl -w use strict; use utf8; +use autodie; use Data::Printer; use Graph::Directed; -binmode STDIN, 'encoding(UTF-8)' or die; -binmode STDOUT, 'encoding(UTF-8)' or die; -binmode STDERR, 'encoding(UTF-8)' or die; +binmode STDIN, 'encoding(UTF-8)'; +binmode STDOUT, 'encoding(UTF-8)'; +binmode STDERR, 'encoding(UTF-8)'; our @choices; our %choices; @@ -90,29 +91,29 @@ foreach my $iy (-2..$#ch) { foreach my $ix (-2..$#ch) { if ($iy==-1) { if ($ix==-1) { - printf "+" or die; + printf "+"; } else { - printf "------" or die; + printf "------"; } } elsif ($ix==-1) { - printf "|" or die; + printf "|"; } elsif ($ix==-2 && $iy==-2) { - printf "V(Y,X)" or die; + printf "V(Y,X)"; } elsif ($iy==-2) { - printf "%5s ", $choices[$ix] or die $!; + printf "%5s ", $choices[$ix]; } elsif ($ix==-2) { - printf "%5s ", $choices[$iy] or die $!; + printf "%5s ", $choices[$iy]; } else { my $v = \( $vab[$iy][$ix] ); $$v ||= [ ]; if (@$$v) { - printf "%5d ", (scalar @$$v) or die $!; + printf "%5d ", (scalar @$$v); } else { - printf "%5s ", "" or die $!; + printf "%5s ", ""; } } } - printf "\n" or die $!; + printf "\n"; } sub drop ($$) { @@ -121,7 +122,7 @@ sub drop ($$) { $ch[$i]{Dropped} = $why; } -print "# quorum A.6(2)\n" or die $!; +print "# quorum A.6(2)\n"; foreach my $i (0..$#choices) { next if $ch[$i]{Dropped}; @@ -131,7 +132,7 @@ foreach my $i (0..$#choices) { drop $i, "quorum ($v < $quorum)"; } -print "# maj. ratio A.6(3)\n" or die $!; +print "# maj. ratio A.6(3)\n"; foreach my $i (0..$#choices) { next if $ch[$i]{Dropped}; @@ -151,17 +152,16 @@ foreach my $ia (0..$#ch) { my $vab = $vab[$ia][$ib]; my $vba = $vab[$ib][$ia]; next unless $vab > $vba; - print "defeat: $choices[$ia] beats $choices[$ib] ($vab > $vba)\n" - or die $!; + print "defeat: $choices[$ia] beats $choices[$ib] ($vab > $vba)\n"; $defeats->add_vertex($ia,$ib); } } -print "# transitive closure A.6(5)\n" or die $!; +print "# transitive closure A.6(5)\n"; my $tdefeats = $defeats->transitive_closure(); -print "# schwartz set A.6(6)\n" or die $!; +print "# schwartz set A.6(6)\n"; my $schwartz = $defeats->copy(); @@ -169,14 +169,13 @@ foreach my $ia (0..$#ch) { foreach my $ib (0..$#ch) { next if $tdefeats->has_edge($ia,$b); next if !$tdefeats->has_edge($b,$ia); - print "not in Schwartz set: $choices[$ia] because $choices[$ib]\n" - or die $!; + print "not in Schwartz set: $choices[$ia] because $choices[$ib]\n"; $schwartz->delete_vertex($ia); last; } } -print "# dropping weakest defeats A.6(7)\n" or die $!; +print "# dropping weakest defeats A.6(7)\n"; my @weakest = (); @@ -195,5 +194,5 @@ foreach my $edge (@{ $schwartz->edges() }) { push @weakest, $edge; } -#p %choices; +b#p %choices; #p @vab;