# Untested my @filesize_names = qw(kilobyte megabyte gigabyte terabyte petabyte exabyte zettabyte yottabyte); my %short_sizes = map { m/^(\w)/; $1 . 'b' => $_ } @filesize_names; my $word = 'kb'; if ( exists $short_sizes{lc $word} ) { say $short_sizes{lc $word}; }