-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathselection-tester.pl
executable file
·53 lines (49 loc) · 1.31 KB
/
selection-tester.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env perl
use strict;
use warnings;
my %func;
LoadFunction ("SelectionBrad.pl", "Brad", \%func);
LoadFunction ("SelectionJoey.pl", "Joey", \%func);
LoadFunction ("SelectionChristian.pl", "Christian", \%func);
foreach my $pokemon (
["MewTwo", "10", "PoGoUTC"],
["Mankey", "10", "Nowhere"],
["Mankey", "10", "PoGoGaslamp"],
["Mankey", "100", "PoGoGaslamp"],
["Select", "100", "PoGoGaslamp"],
["Unown", "80", "Laprasnado"],
["Abra", "100", "PoGoGaslamp"],
["MewTwo", "100", "PoGoRanchoPQ"]
) {
my ($name, $vi, $twitter) = @$pokemon;
my %pokemon = %{{
"name" => $name,
"vi" => $vi,
"twitter" => $twitter
}};
my %contacts;
foreach my $sms_name (keys %func) {
if ($func{$sms_name}->(%pokemon)) {
$contacts{$sms_name} = 1;
}
}
my @contacts = keys %contacts;
print join(" ", @$pokemon, ":", @contacts),"\n";
}
sub LoadFunction {
my ($file, $sms_name, $func_hash) = @_;
return unless (-f $file);
open (IN, "<$file") || die("Unable to open $file:$!");
my $buffer = "";
while (<IN>) {
$buffer .= $_;
}
close IN;
my $func;
eval $buffer;
unless (defined $func) {
print STDERR "ERROR $file $@\n";
} else {
$func_hash->{$sms_name} = $func;
}
}