P
pt
use XML::Simple;
# %List is a hash of hashes.
# Key is an IP number (stored as string, not v-string)
XMLout(\%List, OutputFile => $Fname) or die "XMLout : $Fname" ;
produces:
<opt>
<211.57.214.74 ProbeCount="1" LastProbe="1092087541" />
<204.251.212.93 ProbeCount="1" LastProbe="1095511410" />
<210.40.224.10 ProbeCount="1" LastProbe="1090939270" />
<159.226.50.10 ProbeCount="2" LastProbe="1093911681" />
<213.114.91.47 ProbeCount="1" LastProbe="1093988795" />
....etc...
</opt>
Reading it back in with:
my $HRef = XMLin($Fname) or die "XMLin : $Fname" ;
returns this error:
Uncaught exception from user code:
not well-formed (invalid token) at line 2, column 3, byte 9 at
C:/Program Files/ActiveState/Perl/site/lib/XML/Parser.pm line 187
XML:arser:arse('XML:arser=HASH(0x1b64be8)','*XML::Simple::XML_FILE')
called at C:/Program Files/ActiveState/Perl/site/lib/XML/Simple.pm
line 334
[snip]
I'm guessing it's because my hash key looks like a number, but I can't
find an option to have it quoted during XMLout().
# %List is a hash of hashes.
# Key is an IP number (stored as string, not v-string)
XMLout(\%List, OutputFile => $Fname) or die "XMLout : $Fname" ;
produces:
<opt>
<211.57.214.74 ProbeCount="1" LastProbe="1092087541" />
<204.251.212.93 ProbeCount="1" LastProbe="1095511410" />
<210.40.224.10 ProbeCount="1" LastProbe="1090939270" />
<159.226.50.10 ProbeCount="2" LastProbe="1093911681" />
<213.114.91.47 ProbeCount="1" LastProbe="1093988795" />
....etc...
</opt>
Reading it back in with:
my $HRef = XMLin($Fname) or die "XMLin : $Fname" ;
returns this error:
Uncaught exception from user code:
not well-formed (invalid token) at line 2, column 3, byte 9 at
C:/Program Files/ActiveState/Perl/site/lib/XML/Parser.pm line 187
XML:arser:arse('XML:arser=HASH(0x1b64be8)','*XML::Simple::XML_FILE')
called at C:/Program Files/ActiveState/Perl/site/lib/XML/Simple.pm
line 334
[snip]
I'm guessing it's because my hash key looks like a number, but I can't
find an option to have it quoted during XMLout().