This is prompted by WitchTest - A Tool For Determining If A Woman Is Guilty Of Witchcraft - somewhat modernized...
package Test::Terr'ist; # save as Test/Terr/ist.pm use overload '""' => \&call_upon,fallback => 1; our @charges = ( "dates for coffee breaks without telling place and/or time", "conspires at coffee breaks with the mobile turned off", "reads books without us knowing", "uses key words terrorrists use", "discusses political matters at high level", "can author sophisticated texts", "remembers school physics", "has other suspects on his rolodex", "questions official 9/11 story", # expand as appropriate ); sub suspect { my $inquiry = shift; my $specimen = { name => shift || "Anonymous"}; bless $specimen, $inquiry; } sub call_upon { $_[0]->{name} } sub AUTOLOAD { my $proof = shift; $AUTOLOAD =~ s/.*:://; *{$AUTOLOAD} = sub { $charges[rand @charges] }; goto &$AUTOLOAD; } sub can { my ($self, $func) = @_; # we might be subclassed my $parent = $self->SUPER::can( $func ); return $parent if $parent; my $pkg = ref( $self ) || $self; local $@; my $ref; $ref = eval { local $SIG{__DIE__}; $ref = $self->$func; } or return undef; no strict 'refs'; no warnings 'redefine'; *{ $pkg . '::' . $func } = $ref; $ref; } # XXX (2014-07-24) FIXME - return a NSA::Local object; qw(BND BKA LKA Innenministerium SPD CDU CSU);
#!/usr/bin/perl use Test::Terr'ist; use strict; my $suspect = Test::Terr'ist->suspect(shift || "this individual"); if ( $suspect->can("boom") ) { my %findings; print "$suspect is a Terrorist because:\n"; my @facts = @ARGV ? @ARGV: @Test::Terr'ist::charges; $findings{$suspect->$_}++ for @facts; my $sum; $sum += $findings{$_} for keys %findings; printf " %.2f%%: $_\n", $findings{$_} / $sum * 100, $_ for keys % +findings; } else { print "$suspect is not found to be a terr'ist.\n"; print "please file a bug report for Test::Terr'ist.\n"; print "Thank you.\n"; }
References:
Wie wird man Terrorist? (german)
Guantánamo in Germany
update: Blacklisted
...my 3rd "Silly Uses Of Perl" post after Clock that goes backwards and yet another time module...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Are You A Terr'ist?"
by parv (Parson) on Jul 03, 2009 at 12:12 UTC | |
by Anonymous Monk on Jul 03, 2009 at 12:16 UTC | |
|
Re: "Are You A Terr'ist?"
by Anonymous Monk on Jul 03, 2009 at 12:17 UTC |