Hi.. Actually i have a prob in extracting values from a hash table.. What i did was.. converted an huge xml file into hash table using Data::Dumper.. now when i give a parameter to the script is must find the corresponding value it holds from the hash table... the following script i used to convert the xml file into hash table...


#!/usr/bin/perl # use module use XML::Simple; use Data::Dumper; open(FILE,">Asdf.txt") or die "Can't open the file"; open(ASDF,">zxcv.txt"); # create object $xml = new XML::Simple; # read XML file $data = $xml->XMLin("E:\\progs\\my perl scripts\\resources.xml"); # print output %new = Dumper($data); print FILE %new;


can ne one suggest me a script to do the needful.. i tried the following script but it was in vain...

#!/usr/bin/perl # use module use XML::Simple; # create object $xml = new XML::Simple; # read XML file %new = $xml->XMLin("resources.xml"); print "Enter the parameter:"; chomp($name =<stdin>); $db1='cfi-oracle-jdbc'; $db2='CnetdbProvider'; $a='CFIDS'; $b='WIDDS'; $c='FDRDS'; $d='mssr3'; # access XML data if ($name eq $a || $name eq $b || $name eq $c) { print "jndiName of $name is %new->{resources.jdbc.JDBCProvider}->{cfi- +oracle-jdbc}->{factories}->{CFIDS}->{$jndiName}\n"; } elsif($name eq $d || $name eq $db2) { print "HELLO"; }



wat i tried is if the user input is either $a or$b or $c it must go to "%new->{resources.jdbc.JDBCProvider}->{cfi-oracle-jdbc}->{factories}->{CFIDS}->{$jndiName}" and get the value that jndi holds... i know i'm wrong plz suggest an appropriate code...

Thanking you in advance..

In reply to hash table prob.. by harshhn

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.