在尝试执行以下代码时,我收到以下错误消息:
Use of tied on a handle without * is deprecated at C:/Perl/lib/XML/Parser/Expat.pm.
我听说这可以通过安装 XML::Parser v2.41 来解决。如何安装特定版本的 XML::Parser?
#!usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use Spreadsheet::ParseExcel;
my $FileName = 'sample.xls';
my $xml_file = 'hello.xml';
my $par=$ARGV[0];
my $xml = XMLin(
$xml_file,
KeepRoot => 1,
ForceArray => 1,
);
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse($FileName);
die "Parser not Defined", ".\n" if ( !defined $workbook );
for my $worksheet ( $workbook->worksheets() ) {
# Find out the worksheet ranges
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
for my $row ( $row_min .. $row_max ) {
for my $col ( $col_min .. $col_max ) {
my $cell = $worksheet->get_cell( $row, $col );
next unless $cell;
$xml->{$par} = $cell->value();
}
}
}