Hi,
I'm new to perl and I'm trying to modify some perl code that processes text going out of an SMS gateway. Currently it suppresses all control characters using this line:
$msg =~ s/[[:cntrl:]]+/ /sg; #(remove CR LF, etc. ORIGINAL LINE)
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/[\n\r]/[~^]/sg;
$msg =~ s/[[:cntrl:]]+/ /sg; #(remove CR LF, etc. ORIGINAL LINE)
$msg =~ s/[~^]/[\n\r]/sg;
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?