1 匹配行首 '^' or '\A'断言
区别:当使用m(多行)修饰符时,^匹配每行的行首,而\A仍然仅在整个字符串的开头进行匹配
eg:$_ = "this is\na multi file";
s/^/BOL/g;
#BOL this is
#BOL a multi file
s/\A/BOL/g;
#BOL this is
#a multi file
2 匹配行尾 '$' or '\z'/'\Z'
'$' 在行尾之前进行匹配
$_ = 'Here is some text\n';
/(.*$)/;
print "${1}."
##"Here is some text.";
/(.*$)/s; ##用/s处理新行
print "${1}."
##
"Here is some text
## .";
'$'和'\z'的区别同'^' '\A'
3 '\Z' '\z' 的区别
'\z' 仅仅匹配字符串的末尾
'\Z'仅仅匹配字符串末尾或字符串末尾新行之前
$_ = "here is some text\n";
s/\z/END/; ##匹配'\n'之前的内容
##here is some text
##END
s/\Z/END/; ##匹配字符串结尾