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

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Is your problem solved with the addition of {} around $usernumber or was that a copy mistake? If the problem still exists, read on:

#!/usr/bin/env perl use warnings; use strict; use 5.10.0; my $h= { 'user' => { 'firstname' => 'Joe','lastname' => 'Shmoe'}}; my $h2= { 'user' => 'Finance Department'}; say "yes" if (ref($h->{'user'}) eq "HASH"); say "no" if (not ref($h2->{'user'}) eq "HASH"); #OUTPUT: yes no

As you can see ref() works. So probably you feed the wrong data to ref(). You could use Data::Dumper to print out your $xml to see if it fits your expectation. And print out $xml->{$usernumber}->{"user"} just before your "if"-clause to check what it contains at that crucial moment. If ref() returns "HASH" then you can be really sure that it is a hash that is in there and not the string "Finance Department"

In reply to Re: Parsing hashes with variable structure by jethro
in thread Parsing hashes with variable structure by SomeNoob

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
    [LanX]: no already the pm code I'm allowed to see ... http://www. 1203338;style=css
    [LanX]: understanding this code is like relearning space invaders and donkey Kong at the same time
    [holli]: i saw that thread and figured it`s OPP value too high. i didnt realise its PM code

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (7)
    As of 2017-11-20 21:37 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (294 votes). Check out past polls.