in reply to
cut a string in a string
If you are matching many instances of this (say reading a log file that is 700MB or more and checking each line for this string) then you are likely to find that the performance improves if you:
- tie the match down to the bare minimum of wildcard characters,
- specify everything that you know is going to be in the match,
- and also anchor the match where possible to the beginning and end of the string (or line) so it doesn't have to try iterating over the string...
my $line = "SNMPv2-MI::enterprises.3184.108.40.206.220.127.116.11=INT";
my $match = $1 if $line =~ /^SNMPv2-MI::enterprises([0-9\.]+)=INT$/;