##@all_metrics contains the below array . foreach my $each_metrics_grp(@all_metrics) { $each_metrics_grp =~ s/RTRV(.*)//gi; #my @sub_metrics = split(/'\n'/, $each_metrics_grp); #my ($matched_true) = ( grep m/\"(([A-Z0-9]+)\-(\d+)),/gsi, @sub_metrics); #print "$1\n"; #print "@sub_metrics"; if( $each_metrics_grp =~m/\"(([A-Z0-9]+)\-(\d+)),/gis) { push (@all_head,$1); #print "matched:[$1]\n"; }else{ #print "not matched\n"; }