For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2007 > UNIX DOS perl question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author UNIX DOS perl question
tommo

2007-02-20, 6:58 pm

UNIX DOS perl question

I have a problem with wriing out a text file. I am reading a text file
created on unix. I
chomp the line, do some stuff, and basically write the same line out
again.

However I am running perl on windows and perl wants to write out a CR
LF instead of just
a good old UNIX LF.

$some_string = "fred";
print "$some_string\n";

in HEX get F R E D 0D 0A

or if I write

$some_string = "fred";
print "$some_string\r";

in HEX get F R E D 0D

or

$some_string = "fred";
print "$some_string\n";

in HEX get F R E D 0D 0A


What I want ....is..

in HEX get F R E D 0A

How do I do it..

nobull67@gmail.com

2007-02-20, 6:58 pm

On Feb 20, 6:00 pm, "tommo" <paulv...@gmail.com> wrote:
> UNIX DOS perl question
>
> I have a problem with wriing out a text file. I am reading a text file
> created on unix. I
> chomp the line, do some stuff, and basically write the same line out
> again.
>
> However I am running perl on windows and perl wants to write out a CR
> LF instead of just
> a good old UNIX LF.


> $some_string = "fred";
> print "$some_string\n";
>
> in HEX get F R E D 0D 0A
>
> What I want ....is..
>
> in HEX get F R E D 0A


You need to put the output filehandle into binary mode, or at least
not crlf mode.

Actually the true story is rather scary but to manipulate ASCII Unix
text on Windows you can get away simply using binmode(*STDOUT) which
is wrong but works.

tommo

2007-02-21, 3:58 am

On 20 Feb, 18:30, "nobul...@gmail.com" <nobul...@gmail.com> wrote:
> On Feb 20, 6:00 pm, "tommo" <paulv...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
> You need to put the output filehandle into binary mode, or at least
> not crlf mode.
>
> Actually the true story is rather scary but to manipulate ASCII Unix
> text on Windows you can get away simply using binmode(*STDOUT) which
> is wrong but works.- Hide quoted text -
>
> - Show quoted text -


Thanks Fella.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com