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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.