Perl 在连接(.)中使用未初始化的值,或在slapd_____;munin插件中使用字符串

Perl 在连接(.)中使用未初始化的值,或在slapd_____;munin插件中使用字符串,perl,ldap,munin,Perl,Ldap,Munin,我正在尝试实现用perl编写的slapd_munin插件,对此我几乎一无所知。我得到的错误是: Use of uninitialized value in concatenation (.) or string at /etc/munin/plugins/slapd_localhost line 232, <DATA> line 275. my $searchdn = $ops{$action}->{'search'} . "," . $basedn; 我尝试通过输出所有

我正在尝试实现用perl编写的
slapd_
munin插件,对此我几乎一无所知。我得到的错误是:

Use of uninitialized value in concatenation (.) or string at
/etc/munin/plugins/slapd_localhost line 232, <DATA> line 275.
 my $searchdn = $ops{$action}->{'search'} . "," . $basedn;
我尝试通过输出所有变量/对象进行调试,如下所示:

use Data::Dumper;   # top of script
# [...]
print Dumper(%ops);
print "action = [$action]\n";
print "basedn = [$basedn]\n\n";
my $searchdn = $ops{$action}->{'search'} . "," . $basedn;
当我再次运行它时,我得到的是:

[...] # 15 other variables belonging to $ops
$VAR16 = {
           'info' => 'The graph shows the number of Waiters',
           'search' => 'cn=Waiters',
           'desc' => 'The current number of Waiters',
           'filter' => '(|(cn=Write)(cn=Read))',
           'title' => 'Number of Waiters',
           'label2' => {
                         'read' => 'Read',
                         'write' => 'Write'
                       },
           'vlabel' => 'Waiters'
         };
action = [localhost]
action = [cn=Monitor]

Use of uninitialized value in concatenation (.) or string at /etc/munin/plugins/slapd_localhost line 237, <DATA> line 275.
[…]#15属于$ops的其他变量
$VAR16={
'info'=>'图表显示服务员的数量',
“搜索”=>“cn=服务员”,
'desc'=>'当前服务员人数',
'过滤器'=>'(|(cn=Write)(cn=Read))',
“标题”=>“服务员人数”,
“label2'=>{
“读取”=>“读取”,
“写入”=>“写入”
},
“vlabel”=>“服务员”
};
action=[localhost]
动作=[cn=监视器]
在/etc/munin/plugins/slapd_localhost第237行、第275行的连接(.)或字符串中使用未初始化的值。
因为所有的变量似乎都设置好了,我真的不明白我得到的错误信息

Q:有人能就如何调试此脚本提供建议吗?您应该转储对
%ops
的引用,如中所示

print Dumper \%ops;
这将使调试输出更清晰。为了说明,考虑

的输出。
#! /usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my %h = (foo => { bar => 1 }, baz => { quux => 3 });

print "No reference:\n",
      Dumper(%h),
      "\n",
      "Reference:\n",
      Dumper(\%h);
请注意,在下半部分中,您可以更清楚地看到结构:

No reference: $VAR1 = 'baz'; $VAR2 = { 'quux' => 3 }; $VAR3 = 'foo'; $VAR4 = { 'bar' => 1 }; Reference: $VAR1 = { 'baz' => { 'quux' => 3 }, 'foo' => { 'bar' => 1 } }; 无参考: $VAR1='baz'; $VAR2={ “qux”=>3 }; $VAR3='foo'; $VAR4={ 'bar'=>1 }; 参考: $VAR1={ ‘baz’=>{ “qux”=>3 }, ‘foo’=>{ 'bar'=>1 } }; 你删掉了输出的关键部分。
$VAR15
的值是多少?是
“localhost”
还是别的什么


打印
$searchdn
时,它的值是多少?

是否确实为$basedn分配了一个值?使用引用打印确实很有帮助。很明显,$ops数组实际上包含了插件配置,并且我错误地创建了插件符号链接(在munin world中,您使用符号链接本身向插件传递参数),因此它失败了。