in reply to Removing leading whitespace from a file?

You shouldn't read and write to the file at the same time; instead make a new file, then copy over:
#!/usr/bin/perl -w use strict; use fatal; use File::Copy; open( FH, "<test.txt" ); open( FH2, ">test.txt.tmp" ); while ( <FH> ) { s/^(\s+)//g; print FH2 $_; } close FH; close FH2; move("test.txt.tmp", "test.txt");
Hope this helps,,,

PS. check out perldoc perlrun to learn how to do this in one line.

update: atcroft, runrig and Zaxo: are you guys on a race or something?