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,11 +8,6 @@ zci is_cached => 1;
triggers start => "find anagrams"; triggers start => "find anagrams";
handle remainder => sub {
if ($_ eq ""){
return "No Anagrams Found."
}
my $json = scalar share('words.json')->slurp; my $json = scalar share('words.json')->slurp;
@ -20,6 +15,13 @@ handle remainder => sub {
#print Dumper(\%wordHash); #print Dumper(\%wordHash);
handle remainder => sub {
if ($_ eq ""){
return "No Anagrams Found."
}
# 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 # 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($_)))); my $sorted_string = join("",sort(split(//,lc($_))));