http://www.perlmonks.org?node_id=473740

Lexicon has asked for the wisdom of the Perl Monks concerning the following question:

There seems to be a difference in the parsing if you put whitespace in between a subroutine name and the subroutine parameters. I imagine this is known, and probably even documented somewhere, but I haven't been able to find it. Can anyone explain the difference?

In case it's a bug: I've run the following code on two machines:
This is perl, v5.8.5 built for i386-linux-thread-multi
This is perl, v5.8.6 built for darwin-thread-multi-2level

#!/usr/bin/perl print (sort ( f( 0 ) )); print (sort ( f ( 0 ) )); print (sort ( &f ( 0 ) )); print (sort f( 0 ) ); print (sort f ( 0 ) ); print (sort &f ( 0 ) ); sub f { 1 }

And get the following results

Chromium:~ lexicon$ perl -l little.pl 1 0 1 0 0 1

Update: No offense guys, but you should read the existing comments before replying to a thread. broquaint had already subtly clued me in that f gets called as the sort subroutine in some cases and noth others. I still find the difference surprising, but etcshadow addressed it as just one of those "crazy rules" perl has for ambiguous situations. etcshadow also pointed out the no op unary + operator which I had been using for years for subroutine calls as my %hash = %{+shift};. Although, really, sort &f(0) does the job and has the bonus of looking correct as well.

Update 2: I thought I should also mention, to those who aren't aware, that this will apply to a lot of situations with built in functions. print will try to call your function to get a file handle, for instance.

All the help is much appreciated, of course!