Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Control chars when printing into emails

by Anonymous Monk
on Jan 08, 2002 at 05:00 UTC ( [id://137015]=perlquestion: print w/replies, xml ) Need Help??

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

Greetings, Perl control-character gurus. This lowly perl peon seeks advice on what is probably a very simple control char problem... My script takes input from a text box and prints it into an email (sent using unix sendmail). When I send these emails to myself, my email program (Pegasus mail) shows ~nl~ wherever the user hit return in the original text box, yet other parts of the script which generate *html* from the text input work fine. I presume the ~nl~ means newline, so I have tried adding s/// lines to remove \n, \r, cM, etc. Nothing I have hit upon seems to fix this.
---------------------------- Original code: sub add_email_message { $subject = "New Ad"; $message = "The following ad (number $new_counter) was added. $form_data{'caption_header'} $form_data{'caption'} $form_data{'text'} ...(notice assignment to $message has not reached end quote)... ------------------------------------------ New code: sub add_email_message { $peg_nl = $form_data{'text'}; $peg_nl =~ s/\n/ /g; $subject = "New Ad"; $message = "The following ad (number $new_counter) was added. $form_data{'caption_header'} $form_data{'caption'} $peg_nl ...(notice assignment to $message has not reached end quote)... ----------------------------------
I will reward you with 1000 thank-you's if you can help with this, because then I can go eat dinner! :)

Replies are listed 'Best First'.
Re: Control chars when printing into emails
by wardk (Deacon) on Jan 08, 2002 at 05:38 UTC
Re: Control chars when printing into emails
by jarich (Curate) on Jan 08, 2002 at 09:22 UTC
    Perhaps doing something like the following might help:
    $peg_nl =~ s/\s+/ /g;
    This will replace all tabs, newlines, carriage returns, and multiple spaces each with a single space (which should make it neater).

    Now this might not be desireable if you're intending to deal with plain text because it will mess up any formatting, but HTML isn't supposed to be worried about spacing, so it should be happy (and make your message shorter).

    Jacinta

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://137015]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found