Bash equivalent of perl's pack function ?

Is there an equivalent of perl's pack function in bash ?

Or in other words, how can I achieve the same thing in bash ?

Much appreciated.

There is no pack function, but you can:

# an array
newvar="${array[*]}"
# some variables
newvar="$a $var2 $somevarname"

Is this what you need?