One Unix/Linux boxes, you can   man ascii    to print a table similar to those found in reference manuals.

Below is something I use to generate an ascii table when I'm not not on a *nix machine and don't have a book. It's pretty much the same as your code, just in the table format.

print "Decimal | Octal | Hex | Character\n"; print "--------+-------+-----+----------\n"; my @hs = (0 .. 9, 'A' .. 'F'); for my $r (@hs) { for my $c (@hs) { my $h = hex($r . $c); printf("%-8.8s\| %-6.6s\| %-4.4s\| %-s\n", sprintf("%u", $h), sprintf("%-3.3o", $h), sprintf("%-2.2X", $h), map({ s/\n/\^J/; $_ } sprintf("%c", $h))); } }

Update: Removed padding on last column per parv's suggestion below. Great idea!


In reply to Re: Generating characters (0 to 255) by cmilfo
in thread Generating characters (0 to 255) by parv

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.