Open a file in UNIX mode

hi,

The function

open(OUTPUT, ">$output_filename");  #opens the file in (DOS) windows mode.

how to open the output file in unix mode.

please suggest.

thanks.

Can you be more specific? You can find more details under below link
open - perldoc.perl.org

my output file is getting generated in windows(DOS) mode and contains ^M characters.

I need to open the file in unix mode so that i could invoke a command in the script itself to remove the ^M characters once the file is generated.

---------- Post updated at 06:03 PM ---------- Previous update was at 04:28 PM ----------

expecting a reply ......

Are you on a Windows or a Unix/Linux system?

I am on windows system, however use hamilton shell to test and run the script.

You mean the file you are creating itself contains the script to take care of ^M characters?
Can't you manually remove ^M by :%s/^M//g ?

Just trying to understand what you are doing...

hi juzz4fun,

please go through the link

"http://www.unix.com/shell-programming-scripting/217303-regex-split-string-write-output-another-file-2.html"

I hope you will understand what the script does.

The output file generated after the script is run, contains ^M characters. And the output file is generated in Windows (Dos) mode.

I am trying to modify the script in such a way that the output file(build_dll.csh) should get opened in unix mode which will facilitate me to invoke an appropriate command in the script to remove the ^M characters from the output file.

hope the issue is clear now.

Hi,

Try doing unix2dos

Eg : unix2dos file_name (in server itself before getting the file in local system)

can anyone please help me out with the block of script for the problem being discussed.

Thanks.

So you are using Activestate Perl on a Windows box and want a file that will transfer to a *nix box with a *nix type of End of Line character?

Try this, I've heard it should work, but haven't tested it yet.

open(OUTPUT, ">$output_filename");  #opens the file in (DOS) windows mode
binmode OUTPUT;

Then make sure your print lines use "\n", when writing to OUTPUT. It should translate it to "LF" only, not "CRLF" as Windows likes.

Use the command strings to remove ^M character

# strings file_with_control_m > file_without_contol_m