open(FH,"test2.txt"); my @input=; close FH; foreach my $line(@input) { $line =~ s/ s{2,}/\t/s ; } print OUT @input; close(OUT);