Page 1 of 1

Using utils.pl

Posted: Thu May 22, 2014 6:55 am
by brent_weaver
Hello all!!!

Code: Select all

#!/usr/bin/perl -w

#use strict;
use lib "/opt/openitc/nagios/libexec";
use utils;


print "$ERRORS{'OK'}\n";

Code: Select all

# ls /opt/openitc/nagios/libexec/utils.pm
/opt/openitc/nagios/libexec/utils.pm
I would expect that my little sample script would print 0 but this is what happens:

Code: Select all

[06:52]root@OWMaster~/bjw# ./test
Name "main::ERRORS" used only once: possible typo at ./test line 8.
Use of uninitialized value $ERRORS{"OK"} in concatenation (.) or string at ./test line 8.
Any help is much appreciated because this has me at a stand still! Thanks!

Re: Using utils.pl

Posted: Thu May 22, 2014 9:58 am
by tmcdonald
I was able to get it working on my system like so:

Code: Select all

#!/usr/bin/perl -w

use strict;
use lib "/usr/local/nagios/libexec";
use utils;

print "$utils::ERRORS{'OK'}\n";
Just need to reference the namespace properly.