I recently started learning perl and have a question that I’m not finding a clear answer to on the Internet. say I have something like this,
@arr = (1, 2, 3);
$scal = "@arr"
# $scal is now 123.
Is the use of quotes the only way to flatten the array so that each element is stored in the scalar value? It seems improbable but I haven’t found any other ways of doing this. Thanks in advance.
The
joinfunction is commonly used to “flatten” lists. Lets you specify what you want between each element in the resulting string.