Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
The stupid question is the question not asked
 
PerlMonks  

printing text to a file in binary

by einerwitzen (Sexton)
on Jun 23, 2005 at 17:55 UTC ( [id://469539]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

einerwitzen has asked for the wisdom of the Perl Monks concerning the following question:

when I currently print text from a textarea to a file it loses its line breaks. I think that this can be saved by printing in binary instead of ASCII. Is there a way to do that?

Replies are listed 'Best First'.
Re: printing text to a file in binary
by PerlingTheUK (Hermit) on Jun 23, 2005 at 18:01 UTC
    Look for binmode and pack in the perldoc. That way you can save the text as binary. However I am not sure if it also causes the line breaks to be restored.

    Cheers,
    PerlingTheUK
Re: printing text to a file in binary
by GrandFather (Saint) on Jun 23, 2005 at 18:07 UTC
    Show us a sample of the code that is causing you grief. For preference with a sample of the before and after text.

    Perl is Huffman encoded by design.
Re: printing text to a file in binary
by brian_d_foy (Abbot) on Jun 23, 2005 at 18:10 UTC

    Are you sure you had the line breaks in the first place? What you see in the textarea is not necessarily what you are going to get in the CGI program. Google can lead you to many discussions of this.

    Good luck :)

    --
    brian d foy <brian@stonehenge.com>
      it is kind of a content manager, it is a single script that receives text which is actually HTML formatted (tabs and lines and such) and takes the HTML that is sent to it and saves it to a .html file. The created page displays fine, but when downloaded or the source is viewed all the html is just one huge block of text.....
Re: printing text to a file in binary
by TedPride (Priest) on Jun 24, 2005 at 00:57 UTC
    The text from the textarea probably does its line breaks with just \n, while your text editor (Notepad?) requires both \r\n. You should try removing all instances of \r and then replacing \n with \r\n. This will hopefully fix your problem.
Re: printing text to a file in binary
by anonymized user 468275 (Curate) on Jun 24, 2005 at 09:09 UTC
    text areas use \n<BR> instead of \n as line breaks.

    -S

Re: printing text to a file in binary
by orkysoft (Friar) on Jun 25, 2005 at 00:43 UTC
    Perhaps you have the text in a list of lines without linebreaks, and then print them without inserting linebreaks? There are so many things that can go wrong, and your description is so vague, that all of the wildly differing suggestions posted here might be applicable.

    --
    Morbo: "Windmills do not work that way!"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://469539]
Approved by PerlingTheUK
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.