A call for help from the wise monks.I have made an assimilation of the subroutine I am tring to write as little program below, along with its output. I have tried many ways to get into the array embeded in the data structure but am probably missing something very simple.
use strict; use XML::Simple; use Data::Dumper; my ($user, $service) = ('Scarborough','dbjobs'); my $user_hash; #the real input comes from a file and is very much longer $user_hash = XMLin("<SERVICES> <SERVICE name='dbjobs'> <USER>Scarborough</USER> <USER>Whitby</USER> </SERVICE> <SERVICE name='reports'> <USER>Scarborough</USER> </SERVICE> </SERVICES>"); print Dumper($user_hash); #only here for testing if ($$user_hash{SERVICE}->{$service}){ print "$service exists\n"; #Here the problem begins #Why is @users getting a ref to the array my @users = @$user_hash{SERVICE}->{$service}->{USER}; print Dumper(@users); #have tried: foreach my $this_service (@$user_hash{SERVICE}->{ +$service}->{USER}) foreach my $this_user (@users){ print "\n".$this_user." ".$user."\n"; } } __END__ OUTPUT FROM PROGRAM $VAR1 = { 'SERVICE' => { 'dbjobs' => { 'USER' => [ 'Scarborough', 'Whitby' ] }, 'reports' => { 'USER' => 'Scarborough' } } }; dbjobs exists $VAR1 = [ 'Scarborough', 'Whitby' ]; ARRAY(0x1a79ea8) Scarborough
Thank you for your consideration.

In reply to Derefferencing the out put from XMLin() by Scarborough

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.