Dereference the $h
with the @
sigil but follow it with a curly brace:
say sum(@{ $h }{ @letters });
If the thing inside the @{...}
is a simple scalar, the curly braces are optional. So, you can shorten it to
say sum(@$h{ @letters });
The third possible syntax is the Postfix Reference Slicing (needs 5.20+):
say sum($h->@{ @letters });
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…