Try this one...
$db = 'aaa.txt';
open(DATA, "$db"

or die "did not open: $!\n";
@dat = (<DATA>);
close(DATA);
# I assume you meant this to open to rewrite the massaged
# data too? You forgot to tag the open for output.
open(DATA, ">$db"

or die "did not open part 2: $!\n";
foreach $line (@dat)
{
$line =~ s/main/index/g;
# I think the problem with this is that the \s is a pseudo character
# used for matching any whitespace (tab, space, newline? ). You can't
# use that as the substitution character. I'm just replacing it with
# an actual space. You could put multiple spaces if you want.
# $line =~ s/\t/\s/g; #This is not working
$line =~ s/\t/ /g;
# this one should work fine, except that you got the terms reversed

# and you need to escape the backslash on the substitution
# $line =~ s/\a/^/g; #This is not working
$line =~ s/^/\\a/g;
# And last but not least, if you want this to go to the output file...
print DATA $line;
}
close(DATA);