views:

135

answers:

2

I see I can do something like this:

print STDOUT (split /\./, 'www.stackoverflow.com')[1];

and "stackoverflow" is printed. However, this:

print +(split /\./, 'www.stackoverflow.com')[1];

does the same, and this:

print (split /\./, 'www.stackoverflow.com')[1];

is a syntax error. So what exactly is going on here? I've always understood the unary plus sign to do nothing whatsoever in any context. And if "print FILEHANDLE EXPR" works, I would have imagined that "print EXPR" would always work equally well. Any insights?

+16  A: 
Sinan Ünür
+1 The space in the OP's `print (` is throwing him/her off. Whitespace isn't significant, even if it "looks" significant. This isn't Python.
Chris Lutz
This caveat applies to any listop, too! It's just that `print` is the one you're most likely to leave the parentheses off of, and the one you're most likely to accidentally add parens to the first arg of.
hobbs
+8  A: 
mobrule