$^I = ""; while () { s/vorher/nachher/; print; } # aufruf: perl script.pl dateiname