in reply to How to use 'last' / 'next' commands to exit loop?

I'm not clear about what you want next or last to do there, but I think you can simplify your key search like this:

my @act_vars = grep {exists $mapped_vars{$_}} @arr_vars;
Looks like blazar++ read the question better.

After Compline,
Zaxo