roho has asked for the wisdom of the Perl Monks concerning the following question:
I found out (much to my surprise) that join MUST enclose its arguments in parens if it is used in a statement with concatenations. Is this normal behavior for join, or is this a bug? The sample code below shows the effect:
#!/usr/bin/perl use strict; use warnings; my @array = qw( a b c ); print "\nSimple join (without parens) - OK\n"; my $cols = join('],[',@array); print "cols = $cols\n"; print "\nConcatenation and join (without parens)- NOT OK\n"; $cols = '[' . join '],[',@array . ']'; print "cols = $cols\n"; print "\nConcatenation and join (with parens) - OK\n"; $cols = '[' . join('],[',@array) . ']'; print "cols = $cols\n";
"Its not how hard you work, its how much you get done."
Back to
Seekers of Perl Wisdom