I’m trying to parse an OID and extract the #18 but I am unsure on how to write it to count Right to Left using a dot as a delimiter:
1.3.6.1.2.1.31.1.1.1.18.10035
This regex will grab the last value
my $ifindex = ($_=~ /^.*[.]([^.]*)$/);
I haven’t found a way to tweak it to get the value I need yet.
What you need is simpler:
A couple of comments:
^and use.*. Anchor to the end only.[.]is a character class, intended for matching groups of characters. e.g.,[abc]will match either a, b, or c. It should be avoided when matching a single character; just match that character instead. In this case you do need to escape it, since it is a special character:\..\d+for the terms.