I have a array reference which has some number of array references inside it.The nested array references also contains the array references.
Here the $Tree is the array reference it will be array reference , the contents and the nested depth all depends on the xml file.I want to traverse through the nested array $Tree and print the contents.
$key = "a";
$value = "hello";
%myhash = {} ;
push @{ myHash{$key} }, $hello;
print $myHash{$key}."\n";
this script prints
"hello" but has following error message.
Reference found where even-sized list expected at ./test line 5.
can any one help me to fix this problem?? (3 Replies)
I have two arrays
@nextArray contains some files like
\main\1\Xul.xml@@\main\galileo_integration_sjc\0
\main\1\PortToStorageDialog.xml@@\main\galileo_integration_sjc\0
.
.
.
\main\1\PreferencesDialog.xml@@\main\galileo_integration_sjc\0
@otherArray contains some files like
... (2 Replies)
Hi All,
I'm writing a nagios check that will see if our ldap servers are in sync...
I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable
so...eg...let take the single array... (1 Reply)
#!/usr/bin/perl
my @arr=("hello", "how", "are", "you");
$l=length(@arr);
print $l;
This print 1.Why?
How can i print the array size = 4?
I want to store these in an array.
hello
how
are
you
And then i want to access these element through indexing.
How can i do this? (4 Replies)
How can I nest substitutions ? My solution just seems cheap ...
sample data
Cisco Catalyst Operating System Software, Version 235.5(18)
Cisco Catalyst Operating System Software, Version 17.6(7)
Cisco Catalyst Operating System Software, Version 19.6(7)
Cisco Catalyst Operating System... (1 Reply)
Hi,
I have a strange problem with arrays in Perl.
That is to say, for me it is strange and perhaps there is a special reason for it that I do not know of.
Not a real Perl Ace.
This is the program, as an example:
#!/usr/bin/perl -w #-d
use strict;
my $pu;
my $pu_list_cmd;
my... (2 Replies)
I'm just having a bit of trouble running this code. It tells me that there's a syntax error on line 29. Any help appreciated.
#!/usr/bin/perl
#
# Phone Book Application
#
%phonebook = (
"Wayne", '34687368',
"Home", '378643287',
"Work", '017374637',
"School",... (2 Replies)
Hello,
I'm quite new to perl so my question is rather basic and I know there is probably a simple way around it but I can't seem to find it.
I have a medium-length code and there is a part that works with a nested for loop:
foreach my $j(@primpiddelta){
for (my $k=1;... (0 Replies)
I want to pass this array as a parameter.
IFS=$'\n'
fortune_lines=($(fortune | fold -w 30 ))
Inside of this line
screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${fortune_lines}\r"`"
And I am lost at this point.
I am thinking something like this?
Then make it loop..
... (7 Replies)
Hello,
I'm looking at simplfying a function that flattens an array, it uses recursion and filters objects by type but this seems to be a waste of resources to me at least, using conditionals like this seems like a bad idea.
The array can be a generic type, int, string, float but not some... (2 Replies)
Discussion started by: f77hack
2 Replies
LEARN ABOUT DEBIAN
mkdoc::xml::dumper
MKDoc::XML::Dumper(3pm) User Contributed Perl Documentation MKDoc::XML::Dumper(3pm)NAME
MKDoc::XML::Dumper - Same as Data::Dumper, but with XML
SYNOPSIS
use MKDoc::XML::Dumper;
use Test::More 'no_plan';
my $stuff = [ qw /foo bar baz/, [], { hello => 'world', yo => \'boo' } ];
my $xml = MKDoc::XML::Dumper->perl2xml ($stuff);
my $stuff2 = MKDoc::XML::Dumper->xml2perl ($xml);
is_deeply ($stuff, $stuff2); # prints 'ok'
SUMMARY
MKDoc::XML::Dumper provides functionality equivalent to Data::Dumper except that rather than serializing structures into a Perl string, it
serializes them into a generic XML file format.
Of course since XML cannot be evaled, it also provides a mechanism for undumping the xml back into a perl structure.
MKDoc::XML::Dumper supports scalar references, hash references, array references, reference references, and litterals. It also supports
circular structures and back references to avoid creating unwanted extra copies of the same object.
That's all there is to it!
API
my $xml = MKDoc::XML::Dumper->perl2xml ($perl);
Turns $perl into an XML string. For instance:
my $perl = [ qw /foo bar baz/, { adam => 'apple', bruno => 'berry', chris => 'cherry' } ];
print MKDoc::XML::Dumper->perl2xml ($perl);'
Will print something like:
<array id="135338912">
<item key="0">
<litteral>foo</litteral>
</item>
<item key="1">
<litteral>bar</litteral>
</item>
<item key="2">
<litteral>baz</litteral>
</item>
<item key="3">
<hash id="135338708">
<item key="bruno">
<litteral>berry</litteral>
</item>
<item key="adam">
<litteral>apple</litteral>
</item>
<item key="chris">
<litteral>cherry</litteral>
</item>
</hash>
</item>
</array>
As you can see, every object has an id. This allows for backreferencing, so:
my $perl = undef;
$perl = $perl;
print MKDoc::XML::Dumper->perl2xml ($perl);'
Prints something like:
<ref id="135338888">
<backref id="135338888" />
</ref>
For the curious, these identifiers are computed using some perl black magic:
my $id = 0 + $reference;
my $perl = MKDoc::XML::Dumper->perl2xml ($xml);
Does the exact reverse operation as xml2perl().
AUTHOR
Copyright 2003 - MKDoc Holdings Ltd.
Author: Jean-Michel Hiver
This module is free software and is distributed under the same license as Perl itself. Use it at your own risk.
SEE ALSO
MKDoc::XML::Decode MKDoc::XML::Encode
perl v5.10.1 2004-10-06 MKDoc::XML::Dumper(3pm)