0 1 2 3 #### #!/usr/bin/perl use strict; use warnings; open(FH, "<", "test.txt"); open(FH2, ">", "test2.txt" ); while() { s/^(\s+)//g; print FH2 $_; } close FH2; close FH; #### #!/usr/bin/perl use strict; use warnings; open(FH, "<", "test.txt"); my @file = ; close(FH); open(FH, ">", "test.txt" ); foreach (@file) { s/^(\s+)//g; print FH $_; } close FH;