#!/usr/bin/perl use strict; use warnings; $^I = ".bak"; # same as -i option undef $/; # slurp whole files! my $replacement= '\t\n\n'; my $filecontents; while (defined ($filecontents=<>)) { $filecontents =~ s { .*? \K (?=) } { $replacement } x; print $filecontents; }