Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REGULAR EXPRESSION TROUBLE

Status
Not open for further replies.

newbie1006

Technical User
Jun 10, 2011
9
US
The Program 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 strings the string and not the numbers at the end.

Sorry It's so long.

Thank You in advance.
 
Try changing this line:

Code:
 if ($nextline =~ /^(.*)<\/Register/)

To this:

Code:
 if ($nextline =~ /^(.*?)[][[:digit:]:]*<\/Register/)

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top