Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
perl抛出错误“;length()用于/usr/lib64/perl5/IO/Compress/Zlib/Extra.pm第198行的@array(您是指标量(@array)吗?);_Perl_Vsphere - Fatal编程技术网

perl抛出错误“;length()用于/usr/lib64/perl5/IO/Compress/Zlib/Extra.pm第198行的@array(您是指标量(@array)吗?);

perl抛出错误“;length()用于/usr/lib64/perl5/IO/Compress/Zlib/Extra.pm第198行的@array(您是指标量(@array)吗?);,perl,vsphere,Perl,Vsphere,vsphere perl sdk 5.5版安装在centos 7 64位计算机上 以下simpleclient.pl()脚本在centos-7 64位计算机上的/usr/lib64/perl5/IO/Compress/Zlib/Extra.pm行198处抛出错误“在@array(您是指“标量(@array)”上使用的长度() root@localhost vsphere_perl_exp]# cat simpleclient.pl #!/usr/bin/perl use strict; use

vsphere perl sdk 5.5版安装在centos 7 64位计算机上

以下simpleclient.pl()脚本在centos-7 64位计算机上的/usr/lib64/perl5/IO/Compress/Zlib/Extra.pm行198处抛出错误“在@array(您是指“标量(@array)”上使用的长度()

root@localhost vsphere_perl_exp]# cat simpleclient.pl
#!/usr/bin/perl
use strict;
use warnings;
use VMware::VIRuntime;

my %opts = (
    entity => {
    type => "=s",
    variable => "VI_ENTITY",
    help => "ManagedEntity type: HostSystem, etc",
    required => 1
    },
    );
Opts::add_options(%opts);
Opts::parse();
Opts::validate();

Util::connect();

# Obtain all inventory objects of the specified type
my $entity_type = Opts::get_option('entity');
my $entity_views = Vim::find_entity_views(
    view_type => $entity_type);


[root@localhost vsphere_perl_exp]# perl --version

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 25 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
运行带有调试选项的perl将在第11行停止

[root@localhost vsphere_perl_exp]# perl -d ./simpleclient.pl --server 15.218.113.152 --username root --password 'secret' --entity HostSystem

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(./simpleclient.pl:6):    my %opts = (
main::(./simpleclient.pl:7):        entity => {
main::(./simpleclient.pl:8):        type => "=s",
main::(./simpleclient.pl:9):        variable => "VI_ENTITY",
main::(./simpleclient.pl:10):       help => "ManagedEntity type: HostSystem, etc",
main::(./simpleclient.pl:11):       required => 1
  DB<1> main::(./simpleclient.pl:14):   Opts::add_options(%opts);
  DB<1> 
[root@localhostvsphere_perl_exp]#perl-d./simpleclient.pl--server 15.218.113.152--username root--password'secret'--entity HostSystem
从perl5db.pl版本1.37加载数据库例程
编辑器支持可用。
输入h或“h”以获取帮助,或输入“man perldebug”以获取更多帮助。
main:(./simpleclient.pl:6):我的%opts=(
main:(./simpleclient.pl:7):实体=>{
main:(./simpleclient.pl:8):类型=>“=s”,
main:(./simpleclient.pl:9):变量=>“VI_实体”,
main:(./simpleclient.pl:10):help=>“管理身份类型:主机系统等”,
main:(./simpleclient.pl:11):必需=>1
DB main:(./simpleclient.pl:14):选项::添加选项(%Opts);
分贝

我是perl新手,如何调试此脚本?

获取数组长度:

my $length = scalar @array;
要获取字符串的长度,请执行以下操作:

my $length = length("my string");

希望这有帮助。

要获取数组的长度,请执行以下操作:

my $length = scalar @array;
要获取字符串的长度,请执行以下操作:

my $length = length("my string");

希望这有帮助。

这不是抛出异常,而是打印警告

IO::Compress::Zlib::Extra包含代码

for (my $ix = 0; $ix <= length(@$data) -1 ; $ix += 2)

抛出的不是异常,而是打印的警告

IO::Compress::Zlib::Extra包含代码

for (my $ix = 0; $ix <= length(@$data) -1 ; $ix += 2)

在您的代码中的某个地方(您在此处输入的代码中未显示)有语句
length(@array)
。这很可能是不正确的,因为它会给出数组大小的长度,即如果
@array=(“foo”,“bar”)
那么
length(@array)==1
length(2)==1
)在您的代码中,您可以在某个地方找到它(您在此处输入的代码中未显示)具有语句
length(@array)
。这很可能不正确,因为它将给出数组大小的长度,即如果
@array=(“foo”,“bar”)
长度(@array)==1
长度(2)==1
)这为我清除了错误,但save_session.pl仍然挂起。我不知道你在说什么。没有提到
save_session.pl
(或其他任何内容)挂起。根本没有提到
save_session.pl
。啊,很抱歉。这就是我试图在vmware cli上工作的原因。这就是我出错的原因。这为我清除了错误,但save_session.pl仍然挂起。我不知道你在说什么。没有提到
save_session.pl
(或其他任何内容)挂起。根本没有提到
save_session.pl
。啊,对不起。这就是我试图在vmware cli上工作的内容。这就是我遇到错误的原因。