Leser: 22
1
2
3
4
5
6
7
8
## ----------------------
## maa
## ----------------------
## muu
## ----------------------
## mee
## ----------------------
...
1
2
3
4
5
6
7
8
9
10
11
my $orig = "## ----------------------
## muu
## ----------------------"
my $replace = "## Fisch
## Fleisch"
while( <> ){
s/$orig/$replace/;
print;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/perl use strict; use warnings; my $file = 'test.txt'; my $content = do{ local (@ARGV,$/) = $file; <> }; my $orig = "## ---------------------- ## muu ## ----------------------"; my $replace = "## Fisch ## Fleisch"; $content =~ s/\Q$orig/$replace/g; print $content;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/perl use strict; use warnings; my $file = 'test.txt'; my $content = do{ local (@ARGV,$/) = $file; <> }; my $orig = '## ---------------------- ## muu\s\d+ ## ----------------------'; my $replace = "## Fisch ## Fleisch"; $content =~ s/$orig/$replace/g; print $content;
1
2
3
4
5
6
7
## ----------------------
## maa
## ----------------------
## muu 1832
## ----------------------
## mee
## ----------------------