I want to search for all elements in an array which have the same starting set of characters as an element in another array. To make it clear:
@array = ("1a","9","3c");
@temp =("1","2","3");
I want to print only 1a and 3c. When I try to use the following program it prints out all the elements in the array instead of the two I want:
foreach $word (@temp)
{
if( grep /^$word/ , @array)
{
print $_;
}
}
Any insights will be appreciated.