在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
参考《Perl语言入门》的一个正则表达式简单测试程序: 1 #!/usr/bin/perl 2 use warnings; 3 use strict; 4 5 my $pattern=$ARGV[0]; 6 if(not $pattern){ 7 print "Usage: ./ret.pl PATTERN\n"; 8 exit; 9 } 10 print "The pattern is m{$pattern}.\n"; 11 print "Ctrl + D to exit.\n"; 12 print ">"; 13 while(<STDIN>){ 14 chomp(my $line = $_); 15 if($line =~ m{$pattern}){ 16 print "matched: '$`<$&>$''.\n"; 17 } else { 18 print "not matched.\n"; 19 } 20 print ">"; 21 }
|
请发表评论