另外使用未初始化的值

时间:2016-04-05 07:20:42

标签: perl warnings

以下程序的结果给了我一个警告。

  

另外使用未初始化的值(+)

为什么未初始化" +"?我该如何解决这个问题?

#/usr/bin/perl -w
use List::MoreUtils qw(pairwise);

my @result_list=();
my @list1=qw(1 23 321 11 324);
my @list2=qw(23 43 46 45 213 435);
@result_list=pairwise { $a + $b } @list1,@list2;
print "@list1\n@list2\n@result_list\n";

1 个答案:

答案 0 :(得分:3)

修复很简单:不要在不同长度的数组上使用function count_post(){ ?> //get value of droup down by javasctipt and pass it into post arg <select name="select_f" id="select_val" onchange="valueselect(this.value);"> <option value="">select</option> <option value="select_1">select_1</option> <option value="select_2">select_2</option> <option value="select_3">select_3</option> <option value="select_4">select_4</option> </select> <script type="text/javascript"> function valueselect(){ var i = document.getElementById('select_val'); var p = i.options[i.selectedIndex].value; location.href="?p="+p; } </script> <?php $post_array = array('post_type'=>'post', 'posts_per_page'=>-1,'meta_key'=>'ptb_select_1','meta_value'=>$_REQUEST['p']); $cust_posts = new wp_query($post_array); echo "count post-> ".$cust_posts->found_posts; ?> <?php $output = ob_get_clean(); return $output; } add_shortcode( 'get_count', 'count_post' ); 。或者,用零替换缺少的值:

pairwise

在Perl 5.10+中,您可以使用&#34; defined-or&#34;运营商my @result_list = pairwise { ($a || 0) + ($b || 0) } @list1, @list2; 而不是&#34;或&#34; //