harshhn has asked for the wisdom of the Perl Monks concerning the following question:
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..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash table prob..
by sh1tn (Priest) on Dec 21, 2007 at 13:10 UTC | |
|
Re: hash table prob..
by glide (Pilgrim) on Dec 21, 2007 at 13:48 UTC | |
by harshhn (Initiate) on Jan 02, 2008 at 07:28 UTC | |
|
Re: hash table prob..
by FunkyMonk (Bishop) on Dec 21, 2007 at 23:34 UTC |