for my $g (@cg) { if (grep $_ eq $g, @gl) { push @ind,$_; print N "$g\n"; #below is where iam trying to print the #corresponding index val. print S "$csta[$g]\n"; }}