Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   trouble with regular exp. (http://www.go4expert.com/forums/trouble-regular-exp-t26608/)

newbie_10 2Sep2011 19:32

trouble with regular exp.
 
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.

chorny 28Sep2011 20:49

Re: trouble with regular exp.
 
Code:

s/\[\d+:\d+\]$//;


All times are GMT +5.5. The time now is 10:22.