in reply to substitute 4 spaces instead of a tab
- Be sure to use strict; and use warnings;—they will catch bugs in your code so you don't have to.
- Bare filehandles ("FH") are discouraged. Use open(my $fh, "<", $tu), three-argument open.
- You've escaped the tab character so it actually means the literal string \t instead of a tab! Use $line =~ s/\t/ /g;, not \\t
- You're not actually writing the results of your substitution out. You need to open another filehandle for writing, and write to that. Don't open the same file you're reading from, otherwise you may truncate it before you have a chance to read it.
- You need to be careful; there may be tabs used not for indenting (as part of the actual code). You might want to use some anchoring (\A or ^) in your regular expression.
- Your editor or other tools can probably do this already for you, and have already worked out the edge cases so you don't have to. Consider using those.