Sean O'Rourke wrote: > I hope this is wrong, because if not, it breaks this: > > if 1 { do something } > foo $x; > > in weird ways. Namely, it gets parsed as: > > if(1, sub { do something }, foo($x)); > > which comes out as "wrong number of arguments to `if'", which is just > strange.
Any subroutine/function like C<if> that has a signature (parameter list) that ends in a C<&sub> argument can be parsed without the trailing semicolon. So C<if>'s signature is: sub if (bool $condition, &block); So the trailing semicolon isn't required. Likewise I could write my own C<perhaps> subroutine: sub perhaps (bool $condition, num $probability, &block) { return unless $condition; return unless $probability > rand; $block(); } and then code: perhaps $x<$y, 0.25 { print "Happened to be less than\n"} perhaps $x>$y, 0.50 { print "Happened to be greater than\n"} without the trailing semicolons. Damian