Acme-Affinity
view release on metacpan or search on metacpan
a => ['mom', 'dad', 'friend'] },
{ i => 19,
q => "What's the hardest thing you've ever done?",
a => ['say I love you', 'meet the in-laws'] },
{ i => 20,
q => "What's the scariest thing you've ever done?",
a => ['say I love you', 'meet the in-laws'] },
];
# Set you to a purposfully strict set of answers
my $you = [ map { [ $_->{a}[0], $_->{a}[0], 'mandatory' ] } sort { $a->{i} <=> $b->{i} } @$questions ];
my %answers = (); # Bucket for the indexed "me" answers
my $affinity = Acme::Affinity->new;
my @importance = sort { $affinity->importance->{$a} <=> $affinity->importance->{$b} } keys %{ $affinity->importance };
my $i = 0;
for my $question (shuffle @$questions) {
$tc = Term::Choose->new({ prompt => 'How important is this to you?' });
$choice = $tc->choose(\@importance);
push @answer, $choice;
$answers{ $question->{i} } = \@answer;
}
Term::Clear::clear();
# Sorted me answers
my $me = [ map { $answers{$_} } sort { $a <=> $b } keys %answers ];
$affinity = Acme::Affinity->new(
questions => [ map { { $_->{q} => $_->{a} } } @$questions ],
me => $me,
you => $you,
);
print 'Score: ', $affinity->score, "\n";
t/00-compile.t view on Meta::CPAN
use IO::Handle;
open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
my @warnings;
for my $lib (@module_files)
{
# see L<perlfaq8/How can I capture STDERR from an external command?>
my $stderr = IO::Handle->new;
diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
$^X, @switches, '-e', "require q[$lib]"))
if $ENV{PERL_COMPILE_TEST_DEBUG};
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
my @_warnings = <$stderr>;
waitpid($pid, 0);
is($?, 0, "$lib loaded ok");
shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
( run in 1.661 second using v1.01-cache-2.11-cpan-13bb782fe5a )