Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks. I'm trying to cope in a general way with these situations:
use strict; use warnings; use XML::Simple;use Data::Dumper; my $file = './test.xml'; my $a = ['x','y']; my $a1 = [$a]; my %tmp = ( A =>$a1, B => 'z'); XMLout(\%tmp,outputfile=>$file,noattr=>1); %tmp = %{XMLin($file,forcearray=>['A'],noattr=>1)}; print "----------\n"; print $tmp{B}."\n"; print $tmp{A}[0]->[0]."\n"; $a = ['x']; $a1 = [$a]; %tmp = ( A =>$a1, B => 'z'); XMLout(\%tmp,outputfile=>$file,noattr=>1); %tmp = %{XMLin($file,forcearray=>1,noattr=>1)}; print "----------\n"; print $tmp{B}."\n"; print $tmp{A}[0]->[0]."\n"; $a = ['x']; $a1 = [$a]; %tmp = ( A =>$a1, B => 'z'); XMLout(\%tmp,outputfile=>$file,noattr=>1); %tmp = %{XMLin($file,forcearray=>['A'],noattr=>1)}; print "----------\n"; print $tmp{B}."\n"; print $tmp{A}[0]->[0]."\n";
That outputs:
---------- z x ---------- ARRAY(0x653930) x ---------- z Not an ARRAY reference at line 31.
I can only think of evaluating ref($tmp{A}) and ref($tmp{B}) to decide how to operate, since in my code $tmp{A} is an array reference to an array that can have a single element made by an array reference to a single-element array itself, and $tmp{B} is instead a scalar. I guess I'm missing something...

In reply to Re^4: Forcing to anonymous array in XML::simple by rbi
in thread Forcing to anonymous array in XML::simple by rbi

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Discipulus]: Mr haukex from Germany! thanks a lot to the other parteciapant our dear Mr afoken.. ;=)
    [Discipulus]: no, seriously thanks both, i missed 'scientist' and 'floating point' and the resarche was imposible..
    Discipulus go to his cell to bookmark this
    [haukex]: Well to be honest I just did a super search for "every should know floating" ;-)
    [Discipulus]: floating was the keyword and.. to use supersearch is plus sign not a (plus) sin

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (10)
    As of 2017-06-26 20:54 GMT
    Find Nodes?
      Voting Booth?
      How many monitors do you use while coding?

      Results (594 votes). Check out past polls.