On Fri, Dec 16, 2005 at 09:14:52AM -0800, Larry Wall wrote:
: It would be a useful exercise to write tr/// in terms of s///.
: It occurs to me that it'd be awfully useful to have a kind of hash
: that returns any unmatched key unchanged.

Actually, in this case it's handled by the fact that the null key
always matches if nothing longer matches.  So tr/abc/ABC/ turns into

    $match<a> = /{$<> := 'A'}/
    $match<b> = /{$<> := 'B'}/
    $match<c> = /{$<> := 'C'}/
    $match<>  = /./;
    s/<%match>/$<>/g;

or some such.

Larry

Reply via email to