That doesn't work when 0 is in the 'alphabet.' Here's a modified solution that handles 0 properly, which is only 8 more char than yours: It adds the null character to each string, which shouldn't print on most machines (it does on my dos, not on my unix).
sub c { ($_,$a)=@_;s!.!$h{$&}||=($a=~/./g,"$&\0")!ge;y/\0//;$_ }

Update:Fixed code as per chipmunk's comment. It's 54 chars now.

The 15 year old, freshman programmer,
Stephen Rawls

In reply to Re: Re: (Golf) Cryptographer's Tool #1 by srawls
in thread (Golf) Cryptographer's Tool #1 by Masem

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":