use strict;
my $str = 'STEELHEAD-MIB DEFINITIONS ::= BEGIN
IMPORTS
OBJECT-TYPE, MODULE-IDENTITY, NOTIFICATION-TYPE, Unsigned32,
TimeTicks, IpAddress, Counter32, Counter64 FROM SNMPv2-SMI
DateAndTime FROM SNMPv2-TC
products FROM RBT-MIB;
steelhead MODULE-IDENTITY
LAST-UPDATED "201401070000Z"
ORGANIZATION "Riverbed Technology, Inc."
CONTACT-INFO
" Riverbed Technical Support
support@riverbed.com"
DESCRIPTION "Steelhead MIB"
REVISION "201401070000Z"
DESCRIPTION "Connection forwarding cluster incompatible trap"
REVISION "201301250000Z"
DESCRIPTION "Corrections in descriptions of some traps"
REVISION "201210170000Z"
DESCRIPTION "Added trap for CF Peer IPv6 incompatible alarm"
REVISION "201202030000Z"
DESCRIPTION "Updated for 7.0.1"
::= { products 1 }
system OBJECT IDENTIFIER
::= { steelhead 1 }
status OBJECT IDENTIFIER
::= { steelhead 2 }
config OBJECT IDENTIFIER
::= { steelhead 3 }
alarms OBJECT IDENTIFIER
::= { steelhead 4 }
statistics OBJECT IDENTIFIER
::= { steelhead 5 }
--
--
-- SYSTEM
--
--
model OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Appliance model"
::= { system 1 }
serialNumber OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Appliance serial number"
::= { system 2 }
systemVersion OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"System software version string"
::= { system 3 }
--
--
-- STATUS
--
--
systemClock OBJECT-TYPE
SYNTAX DateAndTime
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"System clock time"
::= { status 1 }
health OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Current health of the system. The value is one amongst
Healthy, Admission Control, Degraded, Critical"
::= { status 2 }
serviceStatus OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Current status of the optimization service"
::= { status 3 }';
my $regex = qr/^\w+(?=\s+OBJECT-TYPE)/imp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html