#!/usr/bin/perl -w

 use strict;
use warnings; $_='She is a good girl
and likes helping others
'; s/she/he/i;print "$_"; #he is a good girl
#and likes helping others s/hae/she/i;print "$_"; #he is a good girl
#and likes helping others s/(he)/$@ @/i;print; #he@ @ is a good girl
#and likes helping others s/s$/ours,/m;print; #he@ @ is a good girl
#and likes helping otherours, s/(\w*)ing/$/g;print; #he@ @ is a good girl
#and likes help otherours, $_ ='homeN home ome ooo
'; s/h/i/;print; #iomeN home ome ooo s/o/g/g;print; #igmeN hgme gme ggg s(gme)()g;print; #i123N h123 123 ggg s(n)(pppp)i;print; #i123pppp h123 123 ggg (my $copy = $_) =~ s/\s/__/g;print "$copy$_"; #i123pppp h12__12__ggg
#i123pppp h123 123 ggg #my $copy = $_ =~ s/3\s/__/g;print "$copy$_"; #i123pppp h123 123 ggg
#2i123pppp h12__12__ggg s/(\w*)/\U$/gi;print; #I123PPPP H123 123 GGG s/(\w*)\s(\w*)/\l$/i;print; #i123PPPP 123 GGG s/(GGG)/\u\L$/gi;print; #i123PPPP 123 spGgg print "\u\Lmy name is \Uyy\n"; #My name is YY my @split = split / /,$_;print "@split"; #i123PPPP 123 Ggg my @new_split = split;print"@new_split\n"; #123PPPP 123 Ggg my @new_split1 = split /\s/;print"@new_split1\n"; #123PPPP 123 Ggg my $glue = 'xxx';my $string = join $glue,@new_split;print "$string\n"; #i123PPPPxxx123xxxGgg $_ = 'aaa bb ddd';
my ($next1,$next2,$next3) = /(\S+) (\S+) (\S+)/;print "$next2\n"; #bb my %hash = ($string =~ /([A-Z]+)([-]+)/gi); foreach my $key(keys %hash)
{
print "$key and $hash{$key}\n";
} #PPPPxxx and 123
#i and 123 $_ = "a\nmmmmmmm\nabc\n\s\s\ssdsfs\n";
print "$1\n" if /(.*c$)/gm; #abc my $time = `date`;print "$time"; #Sun Jun 23 21:34:46 HKT 2019 $^I = ".bak"; my $input = <>;

问题:  cat .txt |perl test.pl 后并无备份文件1.txt.bak?

05-11 22:11