trouble with regular exp.

Discussion in 'Perl' started by newbie_10, Sep 2, 2011.

  1. newbie_10

    newbie_10 New Member

    Joined:
    Jun 6, 2011
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    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 a moderator: Sep 2, 2011
  2. chorny

    chorny New Member

    Joined:
    Jun 6, 2010
    Messages:
    20
    Likes Received:
    2
    Trophy Points:
    0
    Home Page:
    http://chorny.net
    Code:
    s/\[\d+:\d+\]$//;
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice