schwern (via RT) wrote:
> This code compiles and executes.
>
> #!/usr/bin/perl -w
>
> sub foo {}
>
> sub wrap (*) { }
>
> wrap foo pre => sub { print "Args: @_\n" };
Or, more concisely for illustrations purposes,
wrap foo 1, 2;
> Note the missing comma after "wrap foo". B::Deparse reveals that everything
> after "foo" is being somehow swept away.
>
> $ perl -MO=Deparse foo.plx
> BEGIN { $^W = 1; }
> sub foo {
>
> }
> sub wrap (*) {
>
> }
> &wrap('foo');
> foo.plx syntax OK
>
>
> Where'd pre go?
A bit of investigation shows that the parser first thinks that 1 and 2
are arguments to foo(), but then it notices the prototype of wrap and
converts foo to a bareword, discarding its arguments. Somehow.