It's important to provide sufficient information so that your problem can be reproduced. You have not stated what $xml is. I've assumed this is an XML::Simple object: it could be a subclass of XML::Simple or, indeed, any class providing an XMLout() method. Do let us know if my assumption is wrong! So, my test code (xml_simple_args.pl) starts with:
use strict; use warnings; use XML::Simple; my $xmlfile = q{xml_simple_args.xml}; my $xml = XML::Simple->new();
It's important to post the code you've actually tested. The assignment to $self produces these messages:
$ xml_simple_args.pl Bareword "Polo" not allowed while "strict subs" in use at ./xml_simple +_args.pl line 9. Execution of ./xml_simple_args.pl aborted due to compilation errors.
and after quoting Polo:
$ xml_simple_args.pl Can't modify constant item in scalar assignment at ./xml_simple_args.p +l line 11, near "]," Bareword "_user_tags" not allowed while "strict subs" in use at ./xml_ +simple_args.pl line 9. Execution of ./xml_simple_args.pl aborted due to compilation errors.
My test code uses:
my $self = { _username => q{Polo}, _user_tags => [], _user_pass => undef, };
I was able to reproduce the first error you posted. The third line of the XML::Simple documentation SYNOPSIS has:
my $xml = XMLout($hashref [, <options>]);
I changed %$self to $self and this worked without error. jethro has provided information about this (above).
I was unable to reproduce your second error: the code you posted worked just fine.
I was unable to reproduce your success with the third version you posted; however, after terminating each statement with a semi-colon, this worked fine as well.
Each successful run produced the same output:
$ cat xml_simple_args.xml <?xml version='1.0' standalone='yes'?> <opt> <_user_pass></_user_pass> <_username>Polo</_username> </opt>
Lessons learned from this exercise:
-- Ken
In reply to Re: XMLout $self hash
by kcott
in thread XMLout $self hash
by tritt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |