use strict ; # now and forever! my $db = 'aaa.txt'; open DATA, "< $db" or die "did not open for reading: $!\n"; my @dat = ; # don't need parentheses, context forced by @dat close DATA; open DATA, "> $db" or die "did not open for writing: $!\n"; foreach my $line (@dat) { # Indent, it's useful! $line =~ s/main/index/g; $line =~ s/\t/ /g; #This is not working $line =~ s/^/\a/g; #This is not working print DATA $line; } close DATA ;