不能用一个未定义的值作为符号引用 [英] Can't use an undefined value as a symbol reference
问题描述
我试图使用一个API,Palo Alto Networks的软件。在code被认为提交的用户名和用户网络登录的ip地址到Web界面。
当我尝试使用的PANAPI与样品code为Windows机器下面的异常被抛出:
不能使用一个未定义的值作为符号引用
C:/Perl/lib/PAN/API.pm线179(#1)潘:: API :: UID ::登录('PAN :: API :: UID = HASH(0x7fd113828598),SCU-DSM22 / pmmertens',172.16.6.117)呼吁在API_events.pl行12
这是code-例如自带的API文档:
#!的/ usr / bin中/ perl的-w使用严格的;
使用PAN :: API;我的$ useridagent = '10 .0.0.99'; #我改变了这对我们的PAN服务器地址我的$ useridapi = PAN :: API :: UID->新建($ useridagent);我的$ USER = $ ENV {} USERDOMAIN'/'$ ENV {USERNAME}。;
我的$ IPADDRESS =解压('W4'的gethostbyname($ ENV {} COMPUTERNAME)); $ useridapi->登录($用户,$ ip地址);
我已经确保所有的变量都正确检索。替换文字值没有帮助。谷歌搜索这个错误止跌回升约软硬参考参考,但我没有看到本规则的任何违规行为在下面的code。
这是从PAN / Api.pm的$ C $一个cblock。 179线是打印开始的地方。
子提交(){
我自$ =转变; 使用IO ::插座:: INET;
使用IO ::插座:: SSL; 我的$ =插座IO ::插座:: INET->新建(PeerAddr => $自> {}服务器,
PeerPort => $自>(港口),
原=> TCP); 我的$ socketssl = IO ::插座:: SSL的> start_SSL($插座,
SSL_VERSION = GT;'使用TLSv1');
打印$ socketssl $自> XML;
$ socketssl->关闭;
$ socketssl-> stop_SSL;
}
这两个IO ::插座:: INET和IO ::插座:: SSL线应该有错误检查。是这样的:
我的$ =插座IO ::插座:: INET->新建(....)
或死无法创建套接字:$!
和
我的$ socketssl = IO ::插座:: SSL的> start_SSL(...)
或死无法启动SSL:.IO ::插座:: SSL :: errstr();
虽然不是死我可能会与鲤鱼去::忏悔。
I'm trying to use an API for a Palo Alto Networks software. The code is supposed to submit username and ipaddress of user network logins to a web interface.
When I try using PANs' API with their sample code for a windows machine the following exception is thrown:
Can't use an undefined value as a symbol reference at
C:/Perl/lib/PAN/API.pm line 179 (#1)
PAN::API::UID::login('PAN::API::UID=HASH(0x7fd113828598)', 'SCU-DSM22/pmmertens', 172.16.6.117) called at API_events.pl line 12
This is the code-example that comes with the API documentation:
#!/usr/bin/perl -w
use strict;
use PAN::API;
my $useridagent = '10.0.0.99'; #I changed this to our PAN server address
my $useridapi = PAN::API::UID->new($useridagent);
my $user = $ENV{USERDOMAIN}.'/'.$ENV{USERNAME};
my $ipaddress = unpack('W4',gethostbyname($ENV{COMPUTERNAME}));
$useridapi->login($user,$ipaddress);
I've ensure that all variables are retrieved correctly. Substituting literal values did not help either. Googling this error turned up references about hard and soft references but I don't see any infractions of these rules in the code below.
This is the codeblock from PAN/Api.pm. Line 179 is where the print starts.
sub submit () {
my $self = shift;
use IO::Socket::INET;
use IO::Socket::SSL;
my $socket = IO::Socket::INET->new(PeerAddr => $self->{server},
PeerPort => $self->{port},
Proto => 'tcp');
my $socketssl = IO::Socket::SSL->start_SSL( $socket,
SSL_version =>'TLSv1');
print $socketssl $self->xml;
$socketssl->close;
$socketssl->stop_SSL;
}
Both the IO::Socket::INET and IO::Socket::SSL lines should have error checking. Something like:
my $socket = IO::Socket::INET->new(....)
or die "Failed to create socket: $!"
And:
my $socketssl = IO::Socket::SSL->start_SSL(...)
or die "Failed to start SSL: ".IO::Socket::SSL::errstr();
Although instead of die I might go with Carp::confess.
这篇关于不能用一个未定义的值作为符号引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!