Hi, i used ForceArray to make sure my <server> element will can be an array. But i when i debug, i found its still an hash Experts help pls
##########Sample input####### <?xml version="1.0" ?> <!DOCTYPE config SYSTEM "fefm_config.dtd"> <config> <server name="example_only" active="true"> <nas_repository_unc>\\corp.dummy.com\d +ev\General_CIFS_Workspace\MobileTest\dev\nas_rep</nas_repository_unc> <nas_archive_unc>\\corp.dummy.com\dev\General_CIFS_Wor +kspace\MobileTest\dev\nas_arc</nas_archive_unc> </server> <mod_minutes>0</mod_minutes> <variables> <variable> <name>email_report</name> <value>duser@dummy.com</value> </variable> </variables> </config> ######## Loading with ForceArray####### Log::Log4perl->easy_init({ # Log level: (DEBUG INFO WARN ERROR FATAL) level=>$DEBUG, layout=>'%d %H FEFM.%P %p > %m%n', file=>">>" . $mSettings->{err_file}, ForceArray => [ "server" ] }); $mLogger = get_logger(); ######### reading the hash ############### foreach my $server_name (@{$mSettings->{server}}) { my $this_srv = $mConf->{server}->{$server_name}; our_exit('SERVER') if(!defined $this_srv); if($this_srv->{active} ne 'true') { ##This is where i am getti +ng the error our_exit('ACTIVE'); next; # process next server }

In reply to XML::Simple ForceArray by dev2dev

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.