This is a nice way to map it out and preserve the spatial relationships of the text. Tabs are changed to ' -> ' and spaces to dots '·' (chr 183 ASCII). This is how my editor displays them when I select the display all chars option. chr 182 ASCII is that funny backwards P symbol ¶ used for newlines. We use the octal naming convention for these chars for convenience. chr 0266 = '¶' and chr 0267 = '·'

In the unlikely event these special chars are included in the text to be processed we hex encode them using the standard URL encoding convention of a % followed by two hex digits. We can then remove the URL encoding to regenerate our original text.

sub show { my @data = @_; for (@data) { s/(\266|\267)/sprintf"%%%02X",ord $1/egm; s/ /chr(0267)/egm; s/\t/ -> /gm; s/\n/chr(0266)."\n"/egm; } return wantarray ? @data : join'',@data; } sub hide { my @data = @_; for (@data) { s/ -> /\t/gm; s/\266//gm; s/\267/ /gm; s/%([0-9a-f][0-9a-f])/chr hex $1/eigm; } return wantarray ? @data : join'',@data; } @data = (<DATA>)[0..7]; print "Original data, including specials\n\n"; print @data; print "\n\nShow invisible chars in data\n\n"; print show(@data); print "\n\nHide and show data - should not change\n\n"; print hide(show(@data)); __DATA__ tab 4 spaces, trailing tab tab and 4 spaces ····4·spaces,·trailing·tab -> ¶ -> ····tab·and·4·spaces¶ -> -> ¶ ¶

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Viewing metasymbols in output? by tachyon
in thread Viewing metasymbols in output? by tshabet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.