-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Etienne Robillard wrote:
| Hi,
|
| Here's my first post on this list :)
|
| For fun, I did a small TODO file in XML and then im attempting to,
| err, read from it via XML::Simple (and XML::Parser).
|
| the docs in XML::Simple says that it is possible to
| reach objects in such a way:
|     print $foo->{ bar }->{ baz }->[1];
|
| The assumption I made is that 'bar' and 'baz' meant different
| 'structures' inside the XML file.
|
| I would love to do just that :)
|
| But things seems not so clever, so I get something like:
|     none>perl test-xml.pl
|     Pseudo-hashes are deprecated at test-xml.pl line 10.
|     Out of memory during "large" request for 1073745920 bytes, total
| sbrk() is 2957312 bytes at test-xml.pl line 10.
|
| Perhaps the latter error message is void, simply because my system
| limits (FreeBSD) are wrongly tuned.. However, the pseudo-hashes thingie
| is quite a medium-pita for my humble knowledge :)
|
| Is their a relative explanation for this behavior ?
|
| Moreover, if I do the DUmper($thingie) shrub, its works and gives back
| the structure I wants.
|
| Here's the 'whole' source of it:
| #!/usr/bin/perl -w
| use strict;
|
| use XML::Simple qw(:strict);
| use Data::Dumper;
|
| my $xml_file = '/home/erob/dev/perl/TODO.pietra.xml';
|
| my $in = XMLin( $xml_file,  ForceArray  =>  1, KeyAttr      =>  [ ],  );
| print $in->{ require }->{ item }->[1];
|
| #print Dumper($in);
| 1;
|

Somehow, the error was not to pay attention to the manual in place.
Sorry for junk-polluting the ether..

Here's the correct DWIWTM:

#!/usr/bin/perl -w
use strict;
use XML::Simple qw(:strict);
use Data::Dumper;

my $xml_file = 'test.xml';

my $xs = new XML::Simple;
my $in = $xs->XMLin( $xml_file, ForceArray  =>  'hello', KeyAttr    =>  1 );

print $in->{ echo }->[0];
1;


Thanks,

erob







-----BEGIN PGP SIGNATURE-----
Comment: quork teht!

iD8DBQFAr3EJfhO/J4JSDfYRAnZVAJ0QsC48/uAVIzx7LS5Tzepc+LII8ACfVsmI
wkkpdekiK6RoGDqFYpg6cDQ=
=q/6G
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to