chapter9.1.pl
#!/usr/bin/perl -w
WangFengQiang A
my $what ='fred|barney';
while(<>){
chomp;
my $what_three = $what x 3;
if(/$what_three/) {
print"It's Matched!\n";
}
else {
print"No Match!\n";
}
}
chapter9.2.pl
#!/usr/bin/perl -w
##CopyRight(C) 2021 By WangFengQiang!
$^I = ".out";
while(<>){
s/Fred/Temp/ig;
s/Wilma/Fred/ig;
s/Temp/Wilma/ig;
print;
}
chapter9.3.pl
#!/usr/bin/perl -w
$^I = ".out";
while(<>){
if(m{#!/usr/bin/perl}){
print"##CopyRight(C) 2021 By WangFengQiang!\n$_";
}
else {
print;
}
}
chapter9.4.pl
#!/usr/bin/perl -w
$^I = ".out";
while(<>){
if(m{copyright}i){
print;
}
if(m{#!/usr/bin/perl}) {
print"#WangFengQiang CopyRight\n$_";
}
else {
print;
}
}
chapter9.5.pl
#!/usr/bin/perl -w
my %a;
foreach(@ARGV){
$a{$_} = 1;
}
while(<>){
if(m/CopyRight/ig) {
delete $a{$ARGV};
}
}
if(%a){
@ARGV = sort keys %a;
$^I = ".out";
while(<>){
print;
if(m{#!/usr/bin}){
print"WangFengQiang A\n";
}
}
}