in reply to Experimental keys on scalar is now forbidden

my @variants = keys $hash{$word}{variants};
What is the right way to write it now?

The "right" way to write it, or rather, the way that will work on any version of Perl 5, is:

my @variants = keys %{ $hash{$word}{variants} };

Update: See also perlreftut, perlref, perldsc, and Experimental push on scalar now forbidden.

As of Perl 5.24, you can also make use of the Postfix Dereference Syntax:

use 5.024; my @variants = keys $hash{$word}{variants}->%*;

(Update 2: It's actually been present since 5.20, but it was still experimental then and had to be explicitly enabled.)