in reply to replacing one or more newlines with commas

Does this array (@test) actually have more than one item in it? It's hard to tell, since we don't know what the 'pram' function does. It appears that you want to end up with an array like this: [text, text2, text3].

If 'pram' actually returns a single value (which you happen to be assigning to an array), you should assign it to a scalar, then use a pattern with split to accomplish what you want. There's no sense in replacing the newlines with a comma, just so you can split them again.

$test = pram("test"); @array = split /\n+/$test/;
...and now @array has each item in its own element.