2012-01-04 23 views
5

Làm cách nào tôi có thể giải quyết trường hợp này 'Sử dụng vô dụng biến trong ngữ cảnh void'? (Dòng 17)Làm cách nào tôi có thể giải quyết trường hợp này 'Sử dụng vô dụng biến trong ngữ cảnh void'?

sub next { 
    my $page = shift; 

    my $next_stage = $page->{tree}->{nextstage}; 
    my $prev_stage = $page->{stage}; 

    print "Moving from: $prev_stage to $next_stage.\n" if ($DEBUG); 

    if ($next_stage eq "end") { 
     serialize_grabber_conf_answers($page, $config_file_tmp); 
     $grabber_initialized = 1; 
     return FALSE; 
    } 

    unless (defined ($page->{next_page})) { 
     serialize_grabber_conf_answers($page, $config_file_tmp); 
     my $next_page = ($page, $config_file_tmp, $next_stage); 
     $next_page->{stage} = $next_stage; 
     $page->{next_page} = $next_page; 
     $next_page->{prev_page} = $page; 
    } 

    return FALSE; 
    } 

Cảm ơn

+3

http://perldoc.perl.org/perldiag.html và http://perldoc.perl.org/diagnostics.html – toolic

+1

[perldata] (http://perldoc.perl.org/perldata.html#List -giá trị-xây dựng), [perlfaq4] (http://perldoc.perl.org/perlfaq4.html#What-is-the-difference-between-a-list-and-an-array?) –

+1

Bạn có các vấn đề khác . next_page không giống như nó là một tham chiếu băm. Bạn đang sử dụng 'nghiêm ngặt' ?? – runrig

Trả lời

9

Dòng vấn đề là

my $next_page = ($page, $config_file_tmp, $next_stage); 

Bạn đang chuyển nhượng đến một đại lượng vô hướng, vì vậy chỉ những thành viên cuối cùng của danh sách sẽ được sử dụng. Các thành viên trước đó bị vứt bỏ - sử dụng vô dụng một biến.

Các vấn đề liên quan