Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by bpoag (Monk)
on Jul 01, 2009 at 21:20 UTC ( [id://776567]=CUFP: print w/replies, xml ) Need Help??

#!/usr/bin/perl ## ## WitchTest v0.1 written 070109:1345 by Bowie J. Poag ## ## Usage: witchtest.pl <"Full Name Of Accused Woman"> ## Example: witchtest.pl "Jane M. Doe" ## ## WitchTest implements a 1692 Salem-compliant witch determination ## algorithm. As a helpful aid to the user, it also suggests what ## should be done with said witch, if detected. ## ## Note: This particular implementation of the algortihm assumes ## that no trial is necessary. ## $suspectedWitch=$ARGV[0]; $witchStatus=""; if ($ARGV[0]) { $witchStatus=1; } else { $witchStatus=1; } if ($witchStatus) { print "\nWitchTest: $suspectedWitch hath been determin'd a witch!\n" +; print "WitchTest: Set light to her! She must be hast'ly burnt at the + stake before she hath tyme to further her evil crafte.\n\n"; } exit();
  • Comment on WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
  • Download Code

Replies are listed 'Best First'.
Re: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by ikegami (Patriarch) on Jul 01, 2009 at 23:14 UTC
    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

      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: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by GrandFather (Saint) on Jul 01, 2009 at 22:56 UTC

    Scripting problems:

    1/ Always use strictures (use strict; use warnings;).

    2/ $suspectedWitch is assigned a value which is never used.

    3/ Initializing $witchStatus is redundant. All following paths replace the value.

    4/ The if ($ARGV[0]) is redundant - both branches of the if perform the same task.

    5/ if ($witchStatus) is redundant - $witchStatus is always true.

    6/ No test is made to determine that a name has actually been passed on the command line.

    7/ Dates are better given using one of the ISO time/date formats to avoid confusion.


    True laziness is hard work
      1. If you used the strict definition of witchcraft, you'd never get to burn anyone.
      2. suspected witches tended to give a lot of information that was never used.
      3. wondering whether a suspect is a witch is pointless, the answer is always yes.
      4. "Tie her up and throw her into the lake. If she drowns, the God did not want her to live because she was a witch. If she doesn't drown, she was using her dark powers and therefore is a witch and has to be burned."
      5. see 3.
      6. Who cares who's that? Burn her! She's a witch!

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        1) I thought about going above and beyond the 1692 Salem spec, but didn't want to confuse the matter. This is also why I omitted any reason for trial. I'd imagine these trials would have been thrown out in Appeals, anyway. Hearsay isn't evidence.

        2) True. I wanted to cut to the chase, however..If a witch is a true witch, then the code works. If the witch is not a witch, but accused by virtue of being named in @ARGV[0], then, she might just as well be a witch, and therefore the code works. She must be burned.

        3) Absolutely. I felt it important to go ahead and perform the test for reasons of code readibility, however. Conditional statements can be tricky, and being so explicit prevents a witch from tampering with the code.

        4) Much like the drowning test for witches, algorithmic simplicity is a goal I try to strive for as well. I omitted any drowning test subroutines, which, I admit, does deviate slightly from the 1692 Salem spec, but I'm not aware of any direct evidence of drowning test.

        5) Saw it, and agree!

        6) I agree. All women who's named are subjected to this test must be witches, by mere virtue of needing to BE tested. My code is algorithmically perfect. We all know witches are a problem these days, and burning at the stake has gone somewhat out of fashion.. I hope to reverse these trends, as I oppose witches and witchcraft of any form. Being such brings me into favor with God, and ensures my next year's crops will be plentiful.
        I think your point 3 is the essence of the original code. It's hidden in what appears, on the surface, to be a legitimate test.

        I think most of the downvoters of that post must have missed that.

      1/ Always use strictures (use strict; use warnings;).
      Actually, in this case, adding warnings would make the program spit out a warning if run without arguments. But it's arguable that the program is actually doing the right thing. It's a sign of a newbie to assume that slapping 'use strict' and/or 'use warnings' on a program magically increases the quality of the program - wearing seatbelts doesn't make you a better driver either. And note that slapping 'use strict' on this correct program actually prevents it from compiling. Doesn't seem like an improvement to me.
      2/ $suspectedWitch is assigned a value which is never used.
      Maybe you see a different program than I do, but I see $suspectedWitch being used in the print statements.
      6/ No test is made to determine that a name has actually been passed on the command line.
      In my universe if ($ARGV[0]) won't be true if there's nothing on the command line.
      7/ Dates are better given using one of the ISO time/date formats to avoid confusion.
      Not of course in the case of the Salem witch hunt. The ISO standard is a standard about the Gregorian calendar. But the colonies were still on a Julian calendar by 1692.

      And after 7 points, you still fail to spot the non lexical variables.

      The only thing I forgot to do is include a Perl module that gives people a sense of humor... Jesus..
        That something a witch would say, burn him, buuuuuuuuurn him ;p
Re: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by ELISHEVA (Prior) on Jul 02, 2009 at 09:22 UTC

    I am clearly lacking a sense of humor, not the least of which because, according to this test, I am infallibly a witch. Which means that the monastery is harboring at least one witch and probably a few more. Unless, of course, you are going to make the claim that women here are exempt from witchdom and witch testing by virtue of being monastery residents. (worked for Caris in Ken Follet's "World Without End"). Personally, I think that's lame.

    Might as well burn me, beth (order of priestesses).

    Update: Looking at your comments more closely I suspect you meant to satire, but it failed (at least for me). Good satire makes it blindingly obvious who the real fools are and has you laughing all the way. If you want a well-done example of witch-test satire see Monty Python witch scene where it is clearly proven from logic that any schoolchild would understand that $witchtest = { burn($witch, $wood) => weigh($witch, $duck) };

      ++ ELISHEVA Perhaps the code should be rewriten so as not to be gender specific as witches can be both male and female.
      WitchTest was not intended for intra-monestary use. It's more directed at our friends in New England, primarily, who have a need to process any possible backlog of witch accusations. I felt that Perl would be an ideal solution, well-suited for their needs.

      Even though there are varying degrees of witches, I suppose, the determination of a woman's propensity for acts of witchcraft is more boolean than scalar. For example, the 1692 Salem spec points out that at one point, a form of traditional white magic was used (in the form of a "witch cake") to determine who a witch was. The story goes that two young girls were afflicted with horrible pains and muscle spasms. Their mother (and her Caribbean indentured servant) prepared a cake made from rye and the urine of her affected daughters, and fed it to a dog. It was believed that the dog, upon consuming the cake, would cause the witch to feel equivalent pain to what she had intended for her victims. Witches were believed to transmit evil by particles/granules/droplets expelled from their eyes, and was eliminated in the effluvia (pee and poo) of the victim, hence the use of urine in the cake.

      Using white magic did not illicit much favor from the judge, as any form of magic departs from Puritan teachings--It's sort of backward logic, considering you're essentially asking the devil for help in defeating the devil. This sort of process would be well suited to automate via recursion, or by the very least, a long-sustained while loop capable of defeating the influence of the devil by means of rapid and sustained cake production and consumption:

      pseudocode:
      while(true) { ## Assuming a shared structure exists to represent cake.. collectUrine(); instantiateCakeObject(); populateCakeObject(urine,rye); bakeCake(); obtainDog(); feedDog(@Cake); monitorSuspectedWitchesForSignsOfDistress(); }

        Ah, but your premise is flawed - it isn't the witch hunters of Salem we need to aid and abet, but the witches. As for the monastery, we have powerful magic here and it isn't just limited to the women (though we do our share).

        Best, beth

Re: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by jhourcle (Prior) on Jul 02, 2009 at 15:56 UTC

    Luckily, some areas use the Dutch witch test, and so I have a certificate from Oudewater stating that I'm not a witch, as I weigh too much to be able to ride a broomstick.

      I'm not aware of any Perl module that can determine the boolean status of a witch based upon weight. I'm curious as to how you might implement this...Can you suggest a patch?
Re: WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft
by shmem (Chancellor) on Jul 03, 2009 at 08:23 UTC

    Perfect - included into my instrumentarium inquisitorum - after one correction:

    - $suspectedWitch=$ARGV[0]; + $suspectedWitch=$ARGV[0] || "This maid";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://776567]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 02:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found