Perl语言入门:第七章习题:输出文件中包含一个大写字母的所有行,不输出一行的内容全是大写的

文件内容:

bash-2.03$ cat file_4_ex_ch7.txt
anonymous attribute demolition grammar rules indices refernces lignA
Align,

ligning.
.
AABB

 

代码:

     80 print "\n----------------------------------exercise_ch7_4--------------------------\n";
     81 while(<>){
     82     if(/[A-Z][a-z]+/){
     83         print $_."\n" ;
     84     }
     85     if(/[a-z][A-Z]/){
     86         print $_."\n" ;
     87     }
     88 }
     89 print "\n----------------------------------exercise_ch7_4--------------------------\n";

 

输出:

----------------------------------exercise_ch7_4--------------------------
anonymous attribute demolition grammar rules indices refernces lignA

Align,


----------------------------------exercise_ch7_4--------------------------

 

posted @ 2019-06-19 11:03  jimy1  阅读(323)  评论(0编辑  收藏  举报
Total Visits
AmazingCounters.com