achs has asked for the wisdom of the Perl Monks concerning the following question:
Likewise the file contains of 100 regs. I want to print out the 'init_val' of all the bit fields of the registers. I have tried writing the script<reg> ... <bit id= 7> <name>A</name> <init_val>1</init_val> </bit> <bit id= 6> <name>B</name> <init_val>0<init_val> </bit> ...likewise bits upto 0 </reg>
But the above code is not working properly. After the first bit field,it is getting exited. It is not going to other bit fields of the reg as well as not other registers in the filewhile($line=<IN>) { .... #reg bit field if($line=~/\<bit\sid\=\"(.*)\"\>/) { $bit_name=$1; ... print "Line no. where the bit field has been found : $.\n\n"; #As 'init_val' occurs on the second line after 'bit id' $line_count=$.+2; print "The incremented value is $line_count\n\n "; #reading the initial_value print "####################\n\n\n"; while($sub_line=<IN>) { print "**********************Entered the second loop****** +************\n\n\n"; print "The line no is $.\n\n"; if($.==$line_count) { if($sub_line=~/\<INIT\_VAL\>(.*)\<\/INIT_VAL\>/) { $bits{"$bit_name"}=$1; print "...................The bit field initial value +is $1......... \n\n" } if($sub_line=~/\<INIT\_VAL\/\>/) { $bits{"$bit_name"}=0; print "The bit field initial value is 0\n\n\n " } } print "End of the Loop\n\n"; %bits=qw(0 0); } print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n"; $.=$line_count; print "THE LINE COUNT IS $.\n\n "; } ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HELP TO WRITE THE PERL CODE
by choroba (Cardinal) on Aug 31, 2015 at 10:03 UTC | |
|
Re: HELP TO WRITE THE PERL CODE
by QuillMeantTen (Friar) on Aug 31, 2015 at 16:20 UTC | |
|
Re: help to write perl code
by poj (Abbot) on Sep 01, 2015 at 08:24 UTC | |
|
Re: HELP TO WRITE THE PERL CODE
by Anonymous Monk on Sep 01, 2015 at 02:39 UTC | |
by Anonymous Monk on Sep 01, 2015 at 03:06 UTC | |
by achs (Initiate) on Oct 06, 2015 at 11:31 UTC | |
by hippo (Archbishop) on Oct 06, 2015 at 12:55 UTC | |
by Anonymous Monk on Oct 07, 2015 at 01:25 UTC | |
|
Re: help to write perl code
by Anonymous Monk on Sep 02, 2015 at 00:29 UTC |