Thread search & replace in Textfile
(15 answers)
Opened by futhark at 2010-11-23 18:31
man kann das, was die option -i macht, auch im script setzen. das wäre dann als kurzes beispiel:
Code (perl): (dl
)
1 2 3 4 5 6 $^I = ""; while (<ARGV>) { s/vorher/nachher/; print; } # aufruf: perl script.pl dateiname indem man $^I auf einen definerten wert setzt, wird automatisch inplace-edit aktiviert. (bei einem wert ungleich dem leerstring wird dieser als suffix für eine backup-datei benutzt.) Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: ![]() ![]() View full thread search & replace in Textfile |