In your print statement, $_ is undefined. Therefore, the string "@$_\n" contains only the newline. Your square brackets create a reference to an anonymous array. The text you see is the expected output when you try to print a reference. All you must do is print the variables you want. (You may use the special variable "$,"
perlvar to format the output.)
} else {
# print "@$_\n", [ @$included, $nextValue ]
local $, = q(, );
print @$included, $nextValue, "\n"
if $currentGoal == $nextValue;
return if $nextValue >= $currentGoal;
}