Hi,
I'm trying to remove some trailing ^M from the end of each line in a file. It works when i print to STDOUT but when I direct the output to another file all the ^M's return. The simple code is:
#!/usr/local/perl5.6.1/bin/perl
open SRC, "<create_dynamic_scripts.sql" or die "Can't open SRC\n";
open STDOUT, ">create_dynamic_scripts.sql.clean" or die "Can't open TGT\n";
while (<SRC>) {
$_ =~ s/\^M$//;
print "$_";
}
close SRC or die "Can't close SRC\n";
close STDOUT or die "Can't close TGT\n";
any ideas?
cheers
simmo
I'm trying to remove some trailing ^M from the end of each line in a file. It works when i print to STDOUT but when I direct the output to another file all the ^M's return. The simple code is:
#!/usr/local/perl5.6.1/bin/perl
open SRC, "<create_dynamic_scripts.sql" or die "Can't open SRC\n";
open STDOUT, ">create_dynamic_scripts.sql.clean" or die "Can't open TGT\n";
while (<SRC>) {
$_ =~ s/\^M$//;
print "$_";
}
close SRC or die "Can't close SRC\n";
close STDOUT or die "Can't close TGT\n";
any ideas?
cheers
simmo