#2
fall_bernana2022-10-20 14:51
回复 楼主 双鱼灵汐
程序代码: use strict; use warnings; use XML::Simple qw(:strict); my $content=""; while (<DATA>) { chomp; $content=$content.$_ } my $config = XMLin($content, KeyAttr => { server => 'name' }, ForceArray => [ 'server', 'address' ]); use Data::Dumper; print Dumper($config); __DATA__ <config logdir="/var/log/foo/" debugfile="/tmp/foo.debug"> <server name="sahara" osname="solaris" osversion="2.6"> <address>10.0.0.101</address> <address>10.0.1.101</address> </server> <server name="gobi" osname="irix" osversion="6.5"> <address>10.0.0.102</address> </server> <server name="kalahari" osname="linux" osversion="2.0.34"> <address>10.0.0.103</address> <address>10.0.1.103</address> </server> </config> $VAR1 = { 'debugfile' => '/tmp/foo.debug', 'server' => { 'kalahari' => { 'osversion' => '2.0.34', 'osname' => 'linux', 'address' => [ '10.0.0.103', '10.0.1.103' ] }, 'sahara' => { 'osversion' => '2.6', 'osname' => 'solaris', 'address' => [ '10.0.0.101', '10.0.1.101' ] }, 'gobi' => { 'osversion' => '6.5', 'osname' => 'irix', 'address' => [ '10.0.0.102' ] } }, 'logdir' => '/var/log/foo/' }; 我新安装的XML::Simple,没有问题,请帖有问题的代码。 |
Can't load 'C:\Users\Aurora\AppData\Local\Temp\par-4175726f7261\cache-e4b50c9567fa6a2839309a62779e4994304ae099\27469b66.xs.dll' for module XML::Parser::Expat: load_file:找不到指定的模块。 at D:/Download/perl/lib/DynaLoader.pm line 193.
at D:/Download/perl/vendor/lib/PAR/Heavy.pm line 140.
Compilation failed in require at XML/Parser.pm line 18.
BEGIN failed--compilation aborted at XML/Parser.pm line 22.
Compilation failed in require at D:/Download/perl/vendor/lib/XML/SAX/Expat.pm line 11.
BEGIN failed--compilation aborted at D:/Download/perl/vendor/lib/XML/SAX/Expat.pm line 11.
Compilation failed in require at (eval 13) line 1.
XML::Simple called at script/getClinical.pl.cp line 25.