trouble with regular exp.

newbie_10's Avatar
Light Poster
The Program code:

Code:
use strict;
use warnings;

my @register_list;

open (FILE, "Peint_FcN.xml"); 

while (my $line = <FILE>) 
			{
        		   if ($line =~ m/<Register>/)				
 		              {
                 		  my $nextline =<FILE>;			      
                                  
				if ($nextline =~ /^(.*)<\/Register/)	
				     {				             {
					push(@register_list, $1);		
				      }
				  else
				      {
					print "You have a problem \n";		
					
			              }
        			}
			}
close (FILE);


foreach (sort(@register_list))							
	{
		#$_=~ s/_u/_1/g;
		print $_ . "\n";
		
	}

OUTPUT:


CHIP_FRA_u_REF_CLK_SEL[4:0]
CHIP_FRAN_u_REF_DIV_K[7:0]
CHIP_FRAN_u_REF_DIV_SEL
FRANu_FRN_BANDSEL_BYP_EN
FRCNu_FRN_BIAS_TRIM
FRCNu_FRN_BW_CNTL[4:0]
FRCNu_FRN_CMSEL
FRCNu_FRN_CORE_SEL
FRCNu_FRN_CTUNE_BYP_EN
FRCNu_FRN_CXC_BANDSEL[4:0]
FRCNu_FRN_CXC_BANDSEL_STA[4:0]
FRCNu_FRN_CXC_CFA_AUTO_ACQ_BYP
FRCNu_FRN_CXC_CFA_BANDSEL_MAX
FRCNu_FRN_CXC_CFA_CNTR_RANK_ADJ
FRCNu_FRN_CXC_CFA_FAIL_STA
FRCNu_FRN_CXC_CFA_LUT_BANDSEL[30:0]
FRCNu_FRN_CXC_CFA_LUT_CD_UNLCK
FRCNu_FRN_CXC_CFA_LUT_CK_DELAY
FRCNu_FRN_CXC_CFA_LUT_CNTR_RANK
FRCNu_FRN_CXC_CFA_LUT_FILTER_LEN[20:0]
FRCNu_FRN_CXC_CFA_LUT_LOL_MARGIN
FRCNu_FRN_CXC_CFA_LUT_OWRT


The code is working exactly the way I have written it work, but I want to work such that


CHIP_FRA_u_REF_CLK_SEL
CHIP_FRAN_u_REF_DIV_K
CHIP_FRAN_u_REF_DIV_SEL
FRANu_FRN_BANDSEL_BYP_EN
FRCNu_FRN_BIAS_TRIM
FRCNu_FRN_BW_CNTL
FRCNu_FRN_CMSEL
FRCNu_FRN_CORE_SEL
FRCNu_FRN_CTUNE_BYP_EN
FRCNu_FRN_CXC_BANDSEL
FRCNu_FRN_CXC_BANDSEL_STA
FRCNu_FRN_CXC_CFA_AUTO_ACQ_BYP
FRCNu_FRN_CXC_CFA_BANDSEL_MAX
FRCNu_FRN_CXC_CFA_CNTR_RANK_ADJ
FRCNu_FRN_CXC_CFA_FAIL_STA
FRCNu_FRN_CXC_CFA_LUT_BANDSEL
FRCNu_FRN_CXC_CFA_LUT_CD_UNLCK
FRCNu_FRN_CXC_CFA_LUT_CK_DELAY
FRCNu_FRN_CXC_CFA_LUT_CNTR_RANK
FRCNu_FRN_CXC_CFA_LUT_FILTER_LEN
FRCNu_FRN_CXC_CFA_LUT_LOL_MARGIN
FRCNu_FRN_CXC_CFA_LUT_OWRT

It takes away the numbers at the end of the string. I need help how to change the regular expression I used in the code to make it work the way I need it to, so it only prints the string and not the numbers at the end.

Sorry It's so long.

Thank You in advance.

Last edited by shabbir; 2Sep2011 at 21:31.. Reason: Code blocks
0
chorny's Avatar, Join Date: Jun 2010
Go4Expert Member
Code:
s/\[\d+:\d+\]$//;