Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Join and Concatenation

by toolic (Chancellor)
on Sep 13, 2013 at 18:03 UTC ( #1053982=note: print w/ replies, xml ) Need Help??


in reply to Join and Concatenation

I don't think this is a join bug. I think it is a matter of operator precedence (see perlop). I think the concatenation operator is enforcing scalar context on the array (hence the 3).

Tip #6 from the Basic debugging checklist (B::Deparse). Look how perl internally places parens:

print "\nConcatenation and join (without parens)- NOT OK\n"; $cols = '[' . join('],[', @array . ']');

If your goal is to enclose all elements of an array with square brackets, then join them with commas, I think a more natural approach uses map:

$cols = join ',', map { "[$_]" } @array;


Comment on Re: Join and Concatenation
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-07-24 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (157 votes), past polls