in reply to WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft

This would be more historically accurate:
use strict; use warnings; use File::Basename qw( basename ); sub usage { my $prog = basename($0); print(STDERR "usage: $prog suspect\n"); exit(1); } sub witch_test { my ($suspect) = @_; return 1 if $suspect->float(); return 0; } my ($suspect) = @ARGV or usage(); my $is_alive = ($is_witch) = eval { witch_test($suspect) ?1:0 }; if ($is_witch) { if ($is_alive) { print("Burn her!\n"); } else { print("God's will has been carried out\n"); } } else { if ($is_alive) { die("Assertion error: Need better witch test\n"); } else { print("What a *cough*tragedy*cough*\n"); } }

Update: Fixed negated logic mentioned by JavaFan

  • Comment on Re: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
  • Download Code

Replies are listed 'Best First'.
Re^2: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by JavaFan (Canon) on Jul 02, 2009 at 09:47 UTC
    But that means that if there's a fatal error during the test, the result is (s)he ain't a witch. Perhaps better:
    my $is_dead = ($is_witch) = !eval {!witch_test($suspect)};
    Then if there's a failure in the test equipment, it can be blamed on the evil powers of the subject, and (s)he then must be a witch.
      Your recommended fix won't work. $is_dead will always be equal to 1 (the number of values returned by !eval{}).
Re^2: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by ysth (Canon) on Jul 02, 2009 at 01:43 UTC