in reply to Re^2: How to call a sub-routine ref
in thread How to call a sub-routine ref
See the documentation on the arrow operator in perlop.
Otherwise, the right side is a method name or a simple scalar variable containing either the method name or a subroutine reference, and the left side must be either an object (a blessed reference) or a class name (that is, a package name). See perlobj.
In the examples, all things on the left hand side return undef, and Perl will call that subroutine reference with the return value. The documentation could be a bit more clear about that undef will also "trigger" that case.
use strict; use Data::Dumper; my $ref = sub { print Dumper \@_ }; ()->$ref; do{}->$ref; ()->$ref(); do{}->$ref(); __END__ $VAR1 = [ undef ]; $VAR1 = [ undef ]; $VAR1 = [ undef ]; $VAR1 = [ undef ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to call a sub-routine ref
by tobyink (Canon) on Oct 22, 2012 at 12:35 UTC | |
by Corion (Patriarch) on Oct 22, 2012 at 12:44 UTC | |
by tobyink (Canon) on Oct 22, 2012 at 15:34 UTC |