in reply to Re: Q regex escape within variable
in thread Q regex escape within variable
Hello.
I'm sorry if my explanation was insufficiently clear.
The reason I omitted most of my code as well as the line number, was that experimenting confirmed that the code lines I've posted were the only ones responsible for the error, and independently of $fName's value.
The error generating part was $fNames[$mex] =~ /$pref/i,
which was intended to return true when for example $fName began with '[case A.2 v6]' and $fNames[$mex] began with the exact same string except that the numbers could have been any other numbers as well, such as '[case A.99 v0]' or '[Case A.1 v123]' but not '[case B.2 v6]'.
Once I have constructed the list of indexes of matching names, I could refer to the subarray and work on it specifically, such as ignoring the prefix and sorting the names independently of it.
I hope this clears things up (but notice the above update saying the problem has been solved already).
Thank you very much.