Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to allow newlines thru but still suppress the other control chars in case they cause trouble with the SMS. Thinking of trying something like:$msg =~ s/[[:cntrl:]]+/ /sg; #(remove CR LF, etc. ORIGINAL LINE)
Is there a cleaner way to do it? Would it be better to use tr rather than s ? Can I exclude ranges of chars rather than substituting?$msg =~ s/[\n\r]/[~^]/sg; $msg =~ s/[[:cntrl:]]+/ /sg; #(remove CR LF, etc. ORIGINAL LINE) $msg =~ s/[~^]/[\n\r]/sg;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CR's and other control chars
by ikegami (Patriarch) on Apr 16, 2009 at 05:06 UTC | |
by maqqaios (Initiate) on Apr 16, 2009 at 06:53 UTC |