Thanks, I've thought a little about the meaning of word "complement" in man
perlop and now everything clear to me. Sorry for Your wasted time.

As an alibi I can say that I've consulted with several known Perl
programmers, they all became confused by this code. Now I can direct them to
man perlop too :)

With best regards, Aleksey Maksimov,
Vladivostok, Russia.


----- Original Message ----- 
From: "Yitzchak Scott-Thoennes via RT" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 26, 2004 4:24 PM
Subject: Re: [perl #32631] perl 5.8.5 tr/0123456789/0123456789/ x00-x09 bug


> On Fri, Nov 26, 2004 at 12:38:50AM -0000, Aleksey Maksimov wrote:
> > $a=\"\\t\";
>
> Assume you mean $a="\t";
>
> > $a=~tr/0123456789/0123456789/cd;
> > print $a;
> >
> > Output:
> > 9
> >
> > The problem persists for all characters between \\x00 and \\x09
inclusive.
> > The output contains 0-9 digit that replaced \\x00-\\x09 code. By the
way,
> > tr/0-9//cd works as expected.
>
> Isn't that what you want?  /cd says the left part is complemented, and to
> delete anything beyond the number of replacements on the right, so it's
> translating characters \x00 through \0x2f and \x3a on up.  Since there
> are replacements ("0123456789") specified for \x00 through \x09,
> those get translated into the digits; any other non-digit character
> gets deleted.
>
> Perhaps you should reread the documentation for tr (perldoc perlop,
> search for SEARCHLIST).

Reply via email to