【perl脚本】打印模式匹配内容(摘自perl入门 第五版)
#!/usr/bin/perluse 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]