I am comparing a string to a regular expression. If the string doesn’t match I want to know the location where the matching stopped in the string
For example if I am comparing my string (aaa) to regular expression (aab) than I want to know on what character the matching stopped. Here the second a.
I tried the following code, but I guess the variable $+[0] works only when strings are matched.
if($str!~/$reg/){
print $+[0]
}
Here the variable is empty. So is it possible to do what I am looking for in perl?