PERL: XML Parse

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

PERL: XML Parse

Post by vietboy505 »

I try to follow the example from XML Parse with foo.

Code: Select all

#!/usr/local/bin/perl

use XML::Simple;

my $ref = XMLin('foo.xml');

#also with my $ref = XMLin();

use Data::Dumper;

print Dumper($config);
print $config->{logdir};
where foo.xml

Code: Select all

<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>
I try to test out foo.pl and get
$VAR1 = undef;
Why is that, it doesn't match the one with from the web.
Post Reply