in reply to One liner asked... :)

The problem you have with tabs is that they aren't exactly 4 (or 8) spaces. They are upto the next TABSTOP...
| | | | | | | | | | 1234567890123456789012345678901234567890 this is\ta test this is a test this was\ta test this was a test
As you can see from the above, the tab character represents a different amount of spaces depending on how close to the next tabstop you are.

Simple substitution of \t for \s{4} will not work. You must know how many spaces are necessary to reach the next stop.

Text::Tabs will correctly expand and contract tabs for you.