foreach (@$data){ $res = join (' ', @$_); } # should be...? foreach (@$data) { $res .= "@$_"; # same as join(" ", @$_); }