I would like to take the non-blank chars in a text and convert them into dots, with the exception of the non-breaking-space pre tab. There may be more than one pre tab in the text. I can do this with one pre tab, but I can't figure out how to extend to more than one. Please help!
$text = "test of this # ? my 0923 5834t674";
.... .. .......... . . .. .... ........
Here's the code that works with one pre tab.
if ($text =~ $nbsp) {
$text =~ s/(.*)$nbsp(.*)//g; # ( ) PUTS TEXT INTO $1, $2, etc.
$tex1 = $1; # WHAT COMES BEFORE THE PRE TAG
$tex2 = $2; # WHAT COMES AFTER
$tex1 =~ s/[^ ]/$repl/g; # BLANK OUT, EXCLUDING SPACES
$tex2 =~ s/[^ ]/$repl/g;
$text = "$tex1$nbsp$tex2";
}
else {
$text =~ s/[^ ]/$repl/g;
}
print "$text\n";
THANKS!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.