http://www.perlmonks.org?node_id=180419


in reply to Removing leading whitespace from a file?

An alternative:

use Tie::File; tie @file, 'Tie::File', 'test.txt'; s/^\s+// for @file;
Not the most efficient solution, but I'd prefer it to setting $^I, if it were in a larger program.

The easiest solution was already mentioned:

perl -i -pe's/^\s+//' test.txt

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.