in reply to unshift single scalar
However, despite your first example (with the "wasteful" @array variable), your English description of what you want to accomplish (putting 'Top' at the start of @output) sounds like you may just have your arguments to unshift in the wrong order. The first argument is the array to modify, the second is the list of items to prepend to the array, so you would use unshift @output, 'Top' even though the end result is to modify @output to contain ('Top', @output). (In your first example, while it is syntactically valid, the end result is that @output is unmodified and @array ends up with the contents (@output, 'Top'), not ('Top', @output).)
|
|---|