# $_ =~ s/(\[.*\]) #match within first [ #charachters inside it ] # \s+ #match a space after this # (\[.*\]).* #match again for the second [ #charachters inside it ] # (SNMP: Get$)/; #match the SNMP part of # the string # print "$1 $2 $3\n";