in reply to Re: Check If 2 Arrays Match
in thread Check If 2 Arrays Match
Unless your ids are always exactly the same length, you might want to replace /($ID)/ with /^$ID$/. Otherwise "123" will match all of the following files: "123", "1234", and "4123".
I also omitted the parentheses around $ID. "(...)" makes Perl do extra work to "capture" whatever is between the parenthesis. Since you already have the value of $ID you don't need to capture it.
Another potential bug. If your id contains fullstops, i.e. '.' or other special regular expresssion characters you should probably escape the id, i.e. /^\Q$ID\E$/. The reason is that Perl will read the dot as a wildcard, so "1.2" will match "1.2", "122", "152", and so on.
Best, beth
|
|---|