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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |