#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my $hash = { 'key' => 'value' }; my %chars; $chars{$_} ++ for split //, join "", %$hash; my $count = keys %chars; say $count;