I want to output array elements in a specific format in Perl.
@myArray = ("A", "B", "C");
$text = something;
Something must be a string ' "A" "B" "C"' (each element is enclosed in double quotes).
However, if @myArrayempty, then $textit should be. I was thinking about using join()for example
$text = "\"" . join("\" \"", @myArray) . "\"";
if ($text eq "\"\"")
{
$text = "";
}
I think this will work. However, is there a more elegant way to do this?
source
share