VSphere Perl SDK версии 5.5 установлен на CentOS 7 64 бит машиныperl throws error "length() используется на @array (вы имели в виду« скаляр (@array) »?) На странице /usr/lib64/perl5/IO/Compress/Zlib/Extra.pm line 198."
Следующая simpleclient.pl (https://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.perlsdk.pg.doc/viperl_modscripts.4.2.html#990705) скрипт выбрасывает ошибку «длину(), используемый на @array (Вы имели в виду "скаляр (@array)" ?) в /usr/lib64/perl5/IO/Compress/Zlib/Extra.pm строке 198. " на centos-7 64-разрядная машина.
[email protected] 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);
[[email protected] 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,
[[email protected] 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>
Я новичок в Perl, как отладить этот скрипт?
В своем коде вы где-то (не показан в коде введенного здесь) иметь заявление 'длину (@array)'. Это скорее всего неверно, так как оно даст вам длину размера массива, то есть если '@array = (" foo "," bar ")' then 'length (@array) == 1' (' length (2) == 1') – TLP
https://rt.cpan.org/Public/Bug/Display.html?id=72505 – choroba