Note that tr/// supports ranges, so this works too: tr|\0-9|A-Za-z|

(IIRC this might not work on systems that aren't ASCII based; perlebcdic)

Update: You said "the first 52 bytes of a character map", but \0-9 is the first 58 bytes. So maybe you want to do tr/\0-3/A-Za-z/? Or only the nonprintable characters with tr/\0-\x1F/A-Za-f/?

Update 2: WebPerl live demo of the following:

use warnings; use strict; print join(" "," ",map {sprintf "%X.",$_} 0..7), "\n"; for my $l (0..15) { printf ".%X", $l; for my $c ( map { chr( $l|($_<<4) ) } 0..7 ) { #$c =~ tr/\0-9/A-Za-z/; # doesn't work correctly! #$c =~ tr/\0-3/A-Za-z/; # option 1 $c =~ tr/\0-\x1F/A-Za-f/; # option 2 print " $c "; } print "\n"; } __END__ 0. 1. 2. 3. 4. 5. 6. 7. .0 A Q 0 @ P ` p .1 B R ! 1 A Q a q .2 C S " 2 B R b r .3 D T # 3 C S c s .4 E U $ 4 D T d t .5 F V % 5 E U e u .6 G W & 6 F V f v .7 H X ' 7 G W g w .8 I Y ( 8 H X h x .9 J Z ) 9 I Y i y .A K a * : J Z j z .B L b + ; K [ k { .C M c , < L \ l | .D N d - = M ] m } .E O e . > N ^ n ~ .F P f / ? O _ o 

In reply to Re: Question about tr (updated) by haukex
in thread Question about tr by harangzsolt33

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.