If you just print an array (as in print @_) there will be nothing to show where each element starts and ends
Technically, there will be something: the value of the special variable $, -- it just happens that it defaults to undef (‡) so the separator used is nothing when printed. But if you change or localize its value to a different value, there will be a separator, without having to stringify the array first.
I wouldn't have mentioned this, but you went on to encourage the use of $" and interpolating the array in a string. If all you are doing is trying to get a separator for printing an array or other list (²), then $, will work without having to interpolate/stringify.
-- pryrt
²: However, $, applies to everything when printing in list context, so local $,=',';print $a, @_, $b will have more separator instances than local $,=undef; local $"=','; print $a, "@_", $b; -- which may or may not be what you want.
³: Also, $, is much easier to use in a Windows cmd.exe one-liner than $". As a workaround, use English to the rescue:
C:\usr\local\share>perl -MEnglish -wle "@_ = qw{a bcd ef}; print qq(@_ +); local $LIST_SEPARATOR=','; print qq(@_)" a bcd ef a,bcd,ef
In reply to Splitting Hairs [tangent to: Splitting in while loop]
by pryrt
in thread Splitting in while loop
by tel2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |