read/parse the json outside the trigger block

master
neil 2012-10-29 16:52:20 -04:00
parent bec9546041
commit e867420f34
1 changed files with 8 additions and 6 deletions

View File

@ -8,18 +8,20 @@ zci is_cached => 1;
triggers start => "find anagrams";
my $json = scalar share('words.json')->slurp;
my %wordHash = %{decode_json($json)};
#print Dumper(\%wordHash);
handle remainder => sub {
if ($_ eq ""){
return "No Anagrams Found."
}
my $json = scalar share('words.json')->slurp;
my %wordHash = %{decode_json($json)};
#print Dumper(\%wordHash);
# Format string to look like hash key by making it lowercase then splitting the string into chars, sort them and finally join back into sorted string
my $sorted_string = join("",sort(split(//,lc($_))));