tritt has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
let's say that I have an object with a definition like:my $self = { _username => Polo, _user_tags = [], _user_pass => undef }
And I want to save the status of the object like an XML file.
I tried first with:
my $data = $xml->XMLout(%$self , XMLDecl => 1, OutputFile => $xmlf +ile, NoAttr=>1 );
which results in:
Options must be name=>value pairs (odd number supplied) at...
Then I tried
foreach (keys %$self) { $hash->{$_} = $self->{$_}; } my $data = $xml->XMLout($hash , XMLDecl => 1, OutputFile => $xmlfi +le, NoAttr=>1 );
with no luck:
Operation "==": no method found, left argument has no overloaded magic, right argument in overloaded package Net::IP at inc/XML/Simple.pm +line 1406
And afterwards:
$hash->{_username} = $self->{_username} $hash->{_user_tags} = $self->{_user_tags} $hash->{_user_pass} = $self->{_user_pass} my $data = $xml->XMLout($hash , XMLDecl => 1, OutputFile => $xmlfile, +NoAttr=>1 );
and that works as I expected giving the XML I need
And the question is, Why the different behaviour if all the options I tried are basically the same?
Thanks to all monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XMLout $self hash
by jethro (Monsignor) on Jul 29, 2011 at 11:55 UTC | |
|
Re: XMLout $self hash
by kcott (Archbishop) on Jul 30, 2011 at 07:18 UTC | |
by tritt (Novice) on Aug 01, 2011 at 08:58 UTC | |
|
Re: XMLout $self hash
by Anonymous Monk on Jul 29, 2011 at 11:31 UTC |