gaojinguan 发表于 2017-5-18 10:18:53

【perl脚本】打印模式匹配内容(摘自perl入门 第五版)

#!/usr/bin/perl
use strict;
use warnings;
while(<>){
chomp;
#if(/YOUR_PATTERN_GOES_HERE/){
#if(/match/){
if(/a/){
print "Matched: | $`<$&>$'|\n";
}
else{
print "No match: |$_|\n";
}
}


运行脚本命令 #/bin/perl test.pl text.txt
页: [1]
查看完整版本: 【perl脚本】打印模式匹配内容(摘自perl入门 第五版)