在连接(。)中使用未初始化的值或在App / DuckPAN / Web.pm第484行

时间:2016-08-24 06:02:14

标签: perl duckduckgo

我正在尝试为duckduckgo开发一个即时回答的好东西。我正在使用codio并在测试代码后,当我尝试在端口5000运行web服务器时,我收到错误:

DDG::ZeroClickInfo  {                                                                                                                                                                                                                                 
    Parents       WWW::DuckDuckGo::ZeroClickInfo                                                                                                                                                                                                      
    public methods (4) : DOES, has_structured_answer, new, structured_answer                                                                                                                                                                          
    private methods (0)                                                                                                                                                                                                                               
    internals: {                                                                                                                                                                                                                                      
        answer_type         "lowest_common_multiple",                                                                                                                                                                                                 
        caller              "DDG::Goodie::LowestCommonMultiple",                                                                                                                                                                                      
        is_cached           1,                                                                                                                                                                                                                        
        is_unsafe           0,                                                                                                                                                                                                                        
        structured_answer   {                                                                                                                                                                                                                         
            data        {                                                                                                                                                                                                                             
                subtitle   "Greatest common factor: 4, 20",                                                                                                                                                                                           
                title      20                                                                                                                                                                                                                         
            },                                                                                                                                                                                                                                        
            templates   {                                                                                                                                                                                                                             
                group   "text"                                                                                                                                                                                                                        
            }                                                                                                                                                                                                                                         
        }                                                                                                                                                                                                                                             
    }                                                                                                                                                                                                                                                 
}                                    


Use of uninitialized value in concatenation (.) or string at /home/codio/perl5/perls/perl-5.18.2/lib/site_perl/5.18.2/App/DuckPAN/Web.pm line 484.              

这是我的LowestCommonMultiple.pm

package DDG::Goodie::LowestCommonMultiple;
# ABSTRACT: Returns the Lowest Common Multiple of the two numbers entered

use strict;
use DDG::Goodie;
use Math::BigInt 

zci answer_type => 'lowest_common_multiple';
zci is_cached   => 1;

triggers startend => 'lcm','lowest common multiple';

handle remainder => sub {


my @numbers = grep(/^\d/, split /(?:\s|,)+/);
 return unless @numbers > 1;

    @numbers = sort { $a <=> $b } @numbers;
    my $formatted_numbers = join(', ', @numbers);
    my $result = $numbers[0] * $numbers[1] / Math::BigInt::bgcd(@numbers);

    return  "Lowest Common multiple of $formatted_numbers is $result.",
    structured_answer => {
      data => {
       title => "$result",
       subtitle => "Lowest common multiple: $formatted_numbers"
     },
     templates => {
       group => "text",
    }
    };


};

1;

0 个答案:

没有答案