Hi,

I try to compare items in two different arrays. This loop works well in another program of mine. But not in the current program i'm working on. Weird....

The output of the program shows Nested quantifiers in regex; marked by <-- HERE........

for $3 (@obsolete_class_declare)         
{
    for $4 (@classB)
    {
        if ($4 =~ /$3/i)          #This line causing problem
        {
            print "$4\n";
            last;
        }
    }
    
}

I found the problem already. I put "**" in the arrays which causes some data reading problem. Solved!

You should not use numbered scalar variables in your perl programs, $1 and $2 and etc are used internally by perl for pattern memory and are read only. If you have meta characters in your array elements just use the \Q option to escape them:

$foo =~ /\Q$bar/;

stuff like ** will be interpreted literally, but $ and @ will still be treated like a variable and interpolated.

This question has already been answered. Start a new discussion instead.