in reply to Bad interpreters coming out

How was the old file generated. What OS are you using. How are you "seeing" the ^M characters? How do you open the input file? How do you open the output file?

True laziness is hard work

Replies are listed 'Best First'.
Re^2: Bad interpreters coming out
by sw (Initiate) on Apr 06, 2011 at 08:32 UTC

    Old files are .pl and .sh, the perl script created by a website which sends the .pl into the debian based system through ssh, the .sh file is generated by the system itself

    the OS is a debian based OS

    The ^M characters are like:

    `cp /tmp/unzip/*.cfg /tmp/unzip/seed`;^M

    That is just one line of the new file, ^M is all over the file everywhere

    I read the file using

     open FH, "< $filename" or die "smth smth";

    I wrote to the file using

     open NF, "> $filename2" or die "blabla";

    I opened it using vim

      It seems exceedingly unlikely that a Perl script running on a *nix system using standard Perl IO would add ^M characters to files. It is much more likely that the characters exist in the original files and that those files were generated or edited on a Windows system.

      A simple test would be to create a fourth file that you write a few test lines to, then check that file for extra ^M characters. If they exist there is something weird with your build of Perl. If they don't exist then either the characters are in the source files, or you have managed to get your write file handle into a strange :crlf layer like state.

      True laziness is hard work