in reply to create an anonymous hash using "map"

Convert use charnames into BEGIN { ...; require charnames; ... } to be able to use %hash as the value for :alias export tag ...

# cat custom-name.pl; perl custom-name.pl use strict; use warnings; use Data::Dump qw[dump]; BEGIN { my $char = ord( q[a] ); my %hash = map { $_ => $char++ } qw[ aey bee ]; print dump( %hash ), qq[\n]; use v5.16; require charnames or die $@; charnames->import( q[:alias] => { %hash, q[cea] => $char } ); } printf qq[aey: %s\ncea: %s\n], qq[\N{aey}], qq[\N{cea}] ; ("bee", 98, "aey", 97) aey: a cea: c

... thanks to the response at https://stackoverflow.com/a/63018246, found via search for "perl begin use require export" as the documentation for use & require was inadequate.

Later I checked again & found use -- what I was really looking for (and realized MetaCPAN makes for a bad search engine for perl non-module documentation)!