1 #!/usr/bin/perl -w 2 3 use strict; 4 use warnings; 5 6 $_='She is a good girl 7 and likes helping others 8 '; 9 10 s/she/he/i;print "$_"; 11 12 #he is a good girl 13 #and likes helping others 14 15 s/hae/she/i;print "$_"; 16 17 #he is a good girl 18 #and likes helping others 19 20 s/(he)/$1@ @/i;print; 21 22 #he@ @ is a good girl 23 #and likes helping others 24 25 s/s$/ours,/m;print; 26 27 #he@ @ is a good girl 28 #and likes helping otherours, 29 30 s/(\w*)ing/$1/g;print; 31 32 #he@ @ is a good girl 33 #and likes help otherours, 34 35 $_ ='homeN home ome ooo 36 '; 37 38 s/h/i/;print; 39 40 #iomeN home ome ooo 41 42 s/o/g/g;print; 43 44 #igmeN hgme gme ggg 45 46 s(gme)(123)g;print; 47 48 #i123N h123 123 ggg 49 50 s(n)(pppp)i;print; 51 52 #i123pppp h123 123 ggg 53 54 (my $copy = $_) =~ s/3\s/__/g;print "$copy$_"; 55 56 #i123pppp h12__12__ggg 57 #i123pppp h123 123 ggg 58 59 #my $copy = $_ =~ s/3\s/__/g;print "$copy$_"; 60 61 #i123pppp h123 123 ggg 62 #2i123pppp h12__12__ggg 63 64 s/(\w*)/\U$1/gi;print; 65 66 #I123PPPP H123 123 GGG 67 68 s/(\w*)\s(\w*)/\l$1/i;print; 69 70 #i123PPPP 123 GGG 71 72 s/(GGG)/\u\L$1/gi;print; 73 74 #i123PPPP 123 spGgg 75 76 print "\u\Lmy name is \Uyy\n"; 77 78 #My name is YY 79 80 my @split = split / /,$_;print "@split"; 81 82 #i123PPPP 123 Ggg 83 84 my @new_split = split;print"@new_split\n"; 85 86 #123PPPP 123 Ggg 87 88 my @new_split1 = split /\s/;print"@new_split1\n"; 89 90 #123PPPP 123 Ggg 91 92 my $glue = 'xxx';my $string = join $glue,@new_split;print "$string\n"; 93 94 #i123PPPPxxx123xxxGgg 95 96 $_ = 'aaa bb ddd'; 97 my ($next1,$next2,$next3) = /(\S+) (\S+) (\S+)/;print "$next2\n"; 98 99 #bb 100 101 my %hash = ($string =~ /([A-Z]+)([0-9]+)/gi); 102 103 foreach my $key(keys %hash) 104 { 105 print "$key and $hash{$key}\n"; 106 } 107 108 #PPPPxxx and 123 109 #i and 123 110 111 $_ = "a\nmmmmmmm\nabc\n\s\s\ssdsfs\n"; 112 print "$1\n" if /(.*c$)/gm; 113 114 #abc 115 116 my $time = `date`;print "$time"; 117 118 #Sun Jun 23 21:34:46 HKT 2019 119 120 $^I = ".bak"; 121 122 my $input = <>;
问题: 1 cat 1.txt |perl test.pl 后并无备份文件1.txt.bak?