From e867420f34f83ed814ff770f51a884b97c2bc7c7 Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 29 Oct 2012 16:52:20 -0400 Subject: [PATCH] read/parse the json outside the trigger block --- lib/DDG/Goodie/FindAnagrams.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/DDG/Goodie/FindAnagrams.pm b/lib/DDG/Goodie/FindAnagrams.pm index 081de8270..94b9c58d9 100644 --- a/lib/DDG/Goodie/FindAnagrams.pm +++ b/lib/DDG/Goodie/FindAnagrams.pm @@ -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($_))));