这可能会有所帮助,并且参考链接示例的点击和试用将有助于您的目的,
#!/usr/bin/perl
use strict;
use warnings;
# Find the location of the substring 'people'
my $string = 'UC_CALLMANAGER [Device name abcde][Device IP address 1.1.1.1][Protocol SIP][Device type 550][Device description 9580 - Cordless][Reason Code 13][IPAddressAttributes 0][UNKNOWN_PARAMNAME:LastSignalRecei';
my $fragment = substr $string, index($string, 'Device description');
my $limit = substr $fragment index($fragment, ']');
print " string: <$string>\n";
print "fragment: <$fragment>\n";
print " FINAL OUTPUT : <$limit>\n";
输出 :
字符串: UC_CALLMANAGER [设备名称 abcde][设备 IP 地址 1.1.1.1][协议 SIP][设备类型 550][设备描述 9580 - 无绳][原因代码 13][IPAddressAttributes 0][UNKNOWN_PARAMNAME:LastSignalRecei
片段:设备描述 9580 - Cordless][原因代码 13][IPAddressAttributes 0][UNKNOWN_PARAMNAME:LastSignalRecei
最终输出:设备描述 9580 - 无绳
有关详细信息,请查看:referenced with diff examples