There is a modeule XML::Parser ..something like this which you can look into.
You can also write your code as open(XML, "x") || die("Cannot open file \n"); my $i = 1; my %hash_try; while(<XML>) { chomp; if (/test_number/) { /<(test_number)>(.*?)<\/(\1)>/; if (defined $2) { $hash_try{$i} = $2; $i++; } } } close(XML); -----Original Message----- From: Sugrue, Sean [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 1:06 PM To: [EMAIL PROTECTED] Cc: Sugrue, Sean Subject: hash I am trying to create a hash that takes an xml input from a file retrieves all lines that has the word test_number in it, splits it to retrieve the actual test number and then when the hash is populated "while" through it and print out the keys and values. I don't really have a good grasp of how to create, populate and manipulate hashes so I'm running into problems. Anyone have a suggestion? Below is a sample of my code not yet finished and some of the text from the xml file. #!/usr/local/bin/perl $i=0; print" trying open a file \n"; open(XML, "temp.xml") || die("Cannot open file \n"); while(<XML>) { if($_=~/test_number/){ @test_number=split/\<|>/,$_; $hash_try{$i}=$test_number[2]; $i++; } } close(XML); while(($key,$value)=(%test)){ print"$key=>$value \n";} XML file sample <begin_program_seg> <section_name>CONTINUITY_seq</section_name> </begin_program_seg> <functional_result> <test_number>1</test_number> <head_num>1</head_num> <site_num>0</site_num> <test_flags alarm='n' reliable_test='y' timeout='n' executed='y' aborted='n' passed='y' ></test_flags> <description><![CDATA[ + dig opn/sht <> CONTINUITY_test ]]></description> <patt_gen_num>0</patt_gen_num> </functional_result> <functional_result> <test_number>2</test_number> <head_num>1</head_num> <site_num>0</site_num> <test_flags alarm='n' reliable_test='y' timeout='n' executed='y' aborted='n' passed='y' ></test_flags> <description><![CDATA[ - dig opn/sht <> CONTINUITY_test ]]></description> <patt_gen_num>0</patt_gen_num> </functional_result> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]