I have a script that would check a xml file and find me strings that are between tags <Register> ...</Register> script is : Code: while (my $line = <FILE>) { if ($line =~ m/<Register>/) { my $nextline =<FILE>; if ($nextline =~ /^(.*)]*<\/Register/) { my $string = $1; push(@register_list, $string); } else { print "You have a problem \n"; } } } which is giving me the following SG_u_EO_RX_FI_RD_WR_PT_OET[4:0] GG_RR_AA_FFER_ASD_u_aSD_DAS_B[99999999] GG_RR_AA_u_aSD_DAS_C[25:0] what can i do so i get only this SG_u_EO_RX_FI_RD_WR_PT_OET GG_RR_AA_FFER_ASD_u_aSD_DAS_B GG_RR_AA_u_aSD_DAS_C