I want to compare an array of string with another array of strings; if it matches, print matched.
Example:
@array = ("R-ID 1.0001", "RA-ID 61.02154", "TCA-ID 49.021456","RCID 61.02154","RB-ID 61.02154");
@var = ("TCA-ID 49", "R-ID 1");
for (my $x = 0; $x <= 4; $x++)
{
$array[$x] =~ /(.+?)\./;
if( ($var[0] eq $1) or ($var[1] eq $1) )
{
print "\n deleted rows are :@array\n";
}
else
{
print "printed rows are : @array \n";
push(@Matrix, \@array);
}
Then I need to compare @var with the @array; if it is matched, print the matched pattern.
Here the entire logic is in a hireartical for loop which gives a new @array in each iteration. so every time this logic is executed @array has different strings.
Then comes with @var it is user input field, this @var can be of any size. So in order to run the logic according to these constraints, I need to iterate the condition inside the if loop when the user input @var size is 3 for example.
So the goal is to match and delete the user input stings using the above mentioned logic. But unfortunately tis logic is not working. Could you please help me out in this issue.
I am not able to compare it in if loop? Can you not usefororwhileto iterate through@array?$vartakes. Is it only two strings you need to match or more? Are the strings space/colon/tab delimited? Please specify exactly the format you are using.