print (1 ? 1 : 0) . 'x'

Richard Clamp richardc at unixbeard.net
Thu May 11 11:08:29 BST 2006


On Thu, May 11, 2006 at 10:59:01AM +0100, O'Shaughnessy, Jamie wrote:
> 
> print (1 ? 1 : 0) . 'x';
> 
> What do you expect this would print?

1

Warnings are your friend.

% perl -we'print (1 ? 1 : 0)."x"'
print (...) interpreted as function at -e line 1.
Useless use of concatenation (.) or string in void context at -e line 1.

What you probably meant to write is:

  print +(1 ? 1 : 0) . 'x';


-- 
Richard Clamp <richardc at unixbeard.net>


More information about the london.pm mailing list