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 |