in reply to Trouble printing default variable in "foreach" loop.

Your main problem is with this one line:

my @hiddenKeys = qq(@cityKeys @distanceKeys);

What it should be is:

my @hiddenKeys = (@cityKeys, @distanceKeys);

With your orginal code, you are not merging those two arrays, but rather merge everything in those two arrays into one string. Try this:

use Data::Dumper; my @a = (1,2); my @b = (3,4); my @c = qq(@a @b); print Dumper(\@a); print Dumper(\@b); print Dumper(\@c);

This gives you an array with one element, and that single element is '1 2 3 4'.

Later when you loop through @hiddenKeys, you got confused and thought "like it's printing the whole array and not just the list element being evaluated". That was just your misunderstanding of the debug output. You have only one hiddenKey and that is a concatenated string of all the keys, which looked like the entire array.