(note, this is in a subroutine, so $s1, $s2, and $msg are the arguments being passed in to this sub.) Now, when I first looked at this I assumed, what's going on is, someone is sending in two strings to be compared, and then a warning is printed out if they do/don't match.

But when I looked through the rest of the code, it seems every time this sub is getting called, arrays are being passed in to it. I was curious how the m (match operator) will function with arrays? does the order of elements inside matter? For example, say I have arrays @arr1 and @arr2, and say I populated them by using a grep function. Now let's say they have the same elements, but they aren't in the same indices. Would that m work when comparing them? (my understanding is they'd get passed in this subroutine as scalar references to the arrays. wouldn't that m end up then comparing their memory address location? will it "know" to look at the contents of the array?)

Is there a better way to do this comparison instead of using the "m"? (considering we might be wanting to compare arrays, scalars, etc.)

The first line of the code you posted simply takes the three first elements of the array (or possibly arrays: if the first array has only 2 elements, then the line picks the two elements of the first array and the first element of the second one) passed to the subroutine. $s1, $s2 and $msg are not arrays, but scalars.

But you should post examples of how this subroutine is called if you want more information.

my understanding: I have two hash references, $a and $b. I get an array which holds the keys of the first hash. I grep this array to find matches of the form w+.w+.w+ (alphanumeric chars with two . delimeters). I similarly get an array of the keys of the has referenced by $b and grep it to find matches of that type. I send these grep results (which are arrays) to that _str_comp subroutine. My confusion is kind of what is being checked for in this context. will I get a positive result in that case so long as the arrays simply contain all the same values, regardless of indeces? (so for example say the keys for the hash referenced by $a are 54.jk.1 and 99.1.99, both would get grepped. Now say the keys for the hash referenced by $b are key1, 99.1.99, and 54.jk.1. then 99.1.99 and 54.jk.1 would get grepped. you'd end up sending the arrays @arr1 = (54.jk.1, 99.1.99) and @arr2 = (99.1.99, 54.jk.1) (references to such arrays). would those be equal under the "m" operation? Or does it actually just look at the scalar context of those arrays (which would be the size of the arrays?)

The sub is being passed the last index number of each array, not their contents.

So, if @arr1 had 3 elements and @arr2 had 5 elements, then the sub would receive 2 and 4 as its first 2 args. Using a regex to compare the numbers does not make sense. It would be better to test using the == numerical comparison operator instead.

thank you so much for clearing this up. I am supposed to go in and rewrite this really long file and there's a lot of stuff in here like that. I guess it seemed kind of counter intuitive to me. This sub is in here, but it's never called to compare strings, it's only ever called to compare array sizes like this!!!! I don't know why it's even in the file.

Clling a sub to compare two numbers (max array subscripts) seems overkill to me. I would compare the array sizes and call the error processing subroutine only if array size differ. It seems clearer to me.