You have the essence of it but it ($") is called the "list separator" (see $LIST_SEPARATOR or $" in perlvar). It determines what character will separate elements of a list or array that has been interpolated into a double quoted string (or double quote-like string, see Quote and Quote like Operators in perlop). Also, I think that the word "null" is not correct as I take that to mean local $" = qq{\0}; ... i.e. the NUL character. As NUL is non-printing the effect would be the same but the code is actually setting $" to a zero-length, empty string which is not the same thing.

You should note that the quoting constructs I habitually use, q{...} and qq{...}, are really the same as single and double quotes respectively. They are not commonly used but they make life much easier when doing Perl one-line commands at the shell or command prompt, which is why I have got into that habit. As a general guide, only use double quotes when you want to interpolate a variable into the string; use single quotes if no interpolation is needed.

As to your working code, I think it will be easier to read and more maintainable if you employ some form of code indentation. This becomes more and more important as projects grow and require multiple developers/maintainers. Have a look around the Monstery at what some of the other Monks do, choose (and adapt if necessary) a scheme that suits you then use it consistently.

In the last expression in the do BLOCK you have concatenated two strings to form the one you want to print. The concatenation is unnecessary since your @binary array could be interpolated in the first string. Using quote marks rather than my usual quoting constructs, your code becomes.

print do { local $" = ''; "Your result is:@binary"; };

I hope these points help to clarify things for you but please ask further if there's something you don't understand.

Cheers,

JohnGG


In reply to Re^5: Concatenate printing a string and array by johngg
in thread Concatenate printing a string and array by spickles

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.