${{ qw<tomatoes cat cat tomatoes> }}{$1}
is
my $ref = { qw<tomatoes cat cat tomatoes> };
${ $ref }{$key}
The inner brackets form an anonymous hash constructor. It creates a hash, assigns the contents of the brackets to it, then returns a reference to it.
The outer brackets are part of the hash dereference. They can be omitted (e.g. $$ref{$key}
instead of ${$ref}{$key}
) when unambiguous (e.g. when dereferencing a simple scalar), but this is not such a circumstance.
One can also dereference using the arrow notation, so one could also have used
{ qw<tomatoes cat cat tomatoes> }->{$1}
The difference is that the version being used is simply a variable lookup, so it doesn't require /e, while the latter is Perl code, so it does require /e.
If you had just
${ qw<tomatoes cat cat tomatoes> }{$1}
that would be the same as
${ "tomatoes" }{$1}
since qw() in scalar context returns the last value. That, in turn, is the same as
$tomatoes{$1}
(except that use strict;
wouldn't allow it) and that's obviously not what you want.