my %codes = ( l => 1, L => 1, i => 1, I => 1, z => 2, Z => 2, e => 3, E => 3, h => 4, H => 4, s => 5, S => 5, G => 6, g => 9, t => 7, T => 7, b => 8, B => 8, o => 0, O => 0 ); my $user = 'pileofdung'; my $translated; for (split //, $user) { $translated .= (defined $codes{$_}) ? $codes{$_} : $_; } print $translated,$/; # p1130fdun9 my $password = 'p113.0f.dun9%'; my $match =0; for (split //, $translated) { $match++ if $password =~ /$_/ } print "they match\n" if $match >= length($password) -2; # you can choose how lax you want to be by # setting an appropriate number of characters that # you want to be different between username and password # in this case if all but 2 characters are the same, it # is a bad password