http://www.perlmonks.org?node_id=1047678

rocketperl has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys i basically have three arrays @cg,@gl and @csta. @gl and @csta are of equal length. I want to print all the occurrence of @cg in @gl and for the corresponding index of matched @gl, i want to print @csta. pls help. When i try this, only the first element of csta gets printed throughout. thanks
for my $g (@cg) { if (grep $_ eq $g, @gl) { push @ind,$_; print N "$g\n"; #below is where iam trying to print the #correspond +ing index val. print S "$csta[$g]\n"; }}